joecool2005 Posted July 26, 2007 Share Posted July 26, 2007 Hi,I have a field with a regular expression like this <asp:TextBox id="SSN" runat="server" MaxLength=9/> <asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ControlToValidate="SSN" ErrorMessage="Sin not valid" ValidationExpression="^\d{9}" Display="Static" Font-Name="verdana" Font-Size="10pt"> <img src="images/error.gif" /> </asp:RegularExpressionValidator> When the field is empty, the regular expression is good. But I don't want that. I want to have 9 digits and nothing else. How can I fix that?Thx Link to comment Share on other sites More sharing options...
jesh Posted July 26, 2007 Share Posted July 26, 2007 To prevent an empty value, you can use an asp:RequiredFieldValidator in addition to the asp:ReqularExpressionValidator. Link to comment Share on other sites More sharing options...
aspnetguy Posted July 26, 2007 Share Posted July 26, 2007 this should work [^0-9]{9} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.