zimmer9
asked on
Is this a proper RegularExpressionValidator for ONLY Numeric values and Dashes: ValidationExpression="/(^[0-9]+([-]*[0-9]+)*$)/"
In an aspx file for an ASP.Net application, is this a proper RegularExpressionValidator for verifying only Numeric values and Dashes:
ValidationExpression="/(^[ 0-9]+([-]* [0-9]+)*$) /"
The acceptable values are:
624-018867-0
734031514-0
004-110077
107671
010115018
<tr>
<td align="left" width="50%" style="font-family: Arial, Helvetica, sans-serif; font-size: small; font-weight: bold;
font-style: normal; color: #00356A; " class="auto-style1" >Account Numb:
<asp:TextBox ID="txtAccntnum" Maxlength="15" runat="server" style="margin-left: 0px;text-align: left;" Width="15%" AutoPostBack="true" ></asp:TextBox>
<asp:RegularExpressionVali dator ID="RegularExpressionValid atorAccoun t" runat="server"
ErrorMessage="Account Invalid. Enter numbers and hyphens."
ControlToValidate="txtAccn tnum"
ValidationExpression="/(^[ 0-9]+([-]* [0-9]+)*$) /">
</asp:RegularExpressionVal idator>
</td>
</tr>
ValidationExpression="/(^[
The acceptable values are:
624-018867-0
734031514-0
004-110077
107671
010115018
<tr>
<td align="left" width="50%" style="font-family: Arial, Helvetica, sans-serif; font-size: small; font-weight: bold;
font-style: normal; color: #00356A; " class="auto-style1" >Account Numb:
<asp:TextBox ID="txtAccntnum" Maxlength="15" runat="server" style="margin-left: 0px;text-align: left;" Width="15%" AutoPostBack="true" ></asp:TextBox>
<asp:RegularExpressionVali
ErrorMessage="Account Invalid. Enter numbers and hyphens."
ControlToValidate="txtAccn
ValidationExpression="/(^[
</asp:RegularExpressionVal
</td>
</tr>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, your description is correct.
- It requires at least one digit
- It allows hyphen characters, but even though multiple hyphen characters are allowed (even in a row like 1---23 ) there must always be at least one digit after them