Help: Need SE for 54 char max excluding LF CR

Results 1 to 2 of 2

Thread: Help: Need SE for 54 char max excluding LF CR

  1. #1
    Join Date
    Dec 1969

    Default Help: Need SE for 54 char max excluding LF CR

    Situation: Need to do client side input validation of a textarea (multiline text box). Users are allowed to enter carriage returns/line feeds. Character length of input should not exceed 54 characters, not includeing CR/LF.<BR><BR>Problem: I have not been able to figure out how to get the length restriction to ignore CR/LF characters, thus each return is counting as two characters towards the limit of 54.<BR><BR>Current Code: &#060;asp:regularexpressionvalidator id="Regularexpressionvalidator1" Runat="server" ControlToValidate="txtName" ErrorMessage="Max length for Name is 54 char" ValidationExpression="(.&#124
    ){0,54}"&#062;&#060;/asp:regularexpressionvalidator&#062;<BR><BR>Any idea whether I can even use SE to handle this situation, or will I have to resort to server side validation?

  2. #2
    Join Date
    Dec 1969

    Default Don't see how to do it...

    ...with nothing but a regular expression.<BR><BR>Best would be to use a simple code validation that does a REPLACE to get rid of all vbCR and vbLF characters and then just do a LEN on the remaining ones.<BR><BR>Basically:<BR> If Len( Replace( Replace( txtName.text, vbCR, "" ), vbLF, "" ) ) &#062; 54 Then oops<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts