简体   繁体   中英

Custom validator - start with issue

<asp:RegularExpressionValidator ID="rev" runat="server"
                    ControlToValidate="txt" Display="Dynamic"                    
                    Text="invalid"
                    ValidationExpression="[AB]\w*" />

The above custom validator should force user to enter values that start with AB and CD but don't know how to add that second CD parameter?

Try this for the regex

(AB|CD)\w*

The | represents an OR

Alternation with The Vertical Bar or Pipe Symbol

Also, have a look at the MSDN guide on Regex's.

I do not think that you want to use the [] judging from your question. Try () instead.

Here is the MSDN documentation I mentioned above

Regular Expressions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM