ASP regular expression slider for multi-line text field

I need to check the text box input length.

The max length property does not work for multi-line text fields.

My regular expression is:

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="The notes has exceeded maximum length." ControlToValidate="txtNotes" Display="Dynamic" ValidationExpression=".{0,500}" ValidationGroup="PO"> *</asp:RegularExpressionValidator> 

The problem that I encountered is when a new line is entered in the text box that checks the validity of the problem.

What do I need to add to ValidationExpression to ignore carriage returns?

thank

+7
regex validation
Aug 17 '11 at 15:02
source share
1 answer

Change .{0,500} to [\s\S]{0,500} . Please note that carriage returns will not be definitely ignored; they will still count on a limit of 500 characters.

Of course, if 500 characters is the size of your database field, then this is exactly what you want.

+11
Aug 17 2018-11-18T00:
source share



All Articles