Regular expression validation problem

Results 1 to 2 of 2

Thread: Regular expression validation problem

  1. #1
    Join Date
    Dec 1969

    Default Regular expression validation problem

    I am trying to create a validation where the user must enter information into a textbox that is in the following format AM1ST_DOMAINUSERNAME The user has to type in AM1ST_DOMAIN part, but after that the text could be anything. Here is what I have that isn&#039;t working.<BR><BR>&#060;asp:RegularExpressionValidat or <BR> id="dentaldate1"<BR> ControlToValidate="userID"<BR> ValidationExpression="AM1ST_DOMAIN\*" <BR> Display="Dynamic"<BR> Font-Name="Verdana" Font-Size="12"<BR> Text="UserID must be in the following format AM1ST_DOMAINUSERNAME"<BR> CssClass="errormessages"<BR> runat=server&#062;<BR> &#060;/asp:RegularExpressionValidator&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: Regular expression validation problem

    I think the problem is that in your ValidationExpression you need to preceed the expression with a $ and you can forget about the * (although it being there doesn&#039;t hurt), i.e.:<BR><BR>$AM1ST_DOMAIN\<BR><BR>The $ means that whatever follows must be at the BEGINNING of the pattern being matched. If you had just:<BR><BR>AM1ST_DOMAIN\*<BR><BR>it would match anything that had AM1ST_DOMAIN\ in it as a substring, such as:<BR><BR>Foo barAM1ST_DOMAIN\foofoo<BR><BR>The $, however, indicates that the AM1ST_DOMAIN\ must appear at the beginning of the string. hth

Posting Permissions

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