使用RegularExpressionValidator限制多行文本框的字数

当文本框的模式设定为多行时,maxlength属性就无效了,这时可以使用RegularExpressionValidator控件,代码如下:

代码
< asp:TextBox  ID ="txtIntroduct"  runat ="server"  TextMode ="MultiLine"
     Height
="120px"  Width ="240px"  class ="input_text"   />
< asp:RegularExpressionValidator  ID ="RegularExpressionValidator2"  ControlToValidate ="txtIntroduct"
     ValidationExpression
="([^.]|.){0,300}"  runat ="server"  SetFocusOnError ="true"  Display ="None"
     ValidationGroup
="AddApply"  ErrorMessage ="简单的介绍,300字以内!" ></ asp:RegularExpressionValidator >
< cc1:ValidatorCalloutExtender  ID ="ValidatorCalloutExtender11"  HighlightCssClass ="validatorCalloutHighlight"
     runat
="server"  Enabled ="True"  TargetControlID ="RegularExpressionValidator2" >
</ cc1:ValidatorCalloutExtender >

 

            

你可能感兴趣的:(Validator)