K
Keith G Hicks
It seems like it would be a reasonably common thing to need to use a regular
expression validator in combination with a required field validator. I'm
doing that on a "new password" page. But I'd rather only use one validador.
Putting 2 validator controls side by side looks funny. For example:
<asp:TextBox ID="txtUserPwd" runat="server" TextMode="Password"
Width="230px"></asp:TextBox><asp:RegularExpressionValidator ID="revUserPwd"
runat="server" ControlToValidate="txtUserPwd" ErrorMessage="Password must be
at least 8 characters in length, contain at least 1 upper case letter, at
least 1 lower case letter and at least 1 digit."
ValidationExpression="^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$">*</asp:
RegularExpressionValidator><asp:RequiredFieldValidatorID="rfvUserPwd"
runat="server" ControlToValidate="txtUserPwd" ErrorMessage="Password is
required.">*</asp:RequiredFieldValidator></td>
When the text box is left blank, the asterisk shows up too far to the right
of the text box. The problem isn't really if there's only one text box to
validate but if you have 3 or 4 stacked on top of each other. If one text
box only has a required field validator, then my asterisks don't line up
vertically. It looks crude that way.
Bottom line is I need to know if it's possible using regular expressions to
also require the value. What can I add to this:
^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$
to make it required. I'm not great with regular expressions.
Thanks,
Keith
expression validator in combination with a required field validator. I'm
doing that on a "new password" page. But I'd rather only use one validador.
Putting 2 validator controls side by side looks funny. For example:
<asp:TextBox ID="txtUserPwd" runat="server" TextMode="Password"
Width="230px"></asp:TextBox><asp:RegularExpressionValidator ID="revUserPwd"
runat="server" ControlToValidate="txtUserPwd" ErrorMessage="Password must be
at least 8 characters in length, contain at least 1 upper case letter, at
least 1 lower case letter and at least 1 digit."
ValidationExpression="^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$">*</asp:
RegularExpressionValidator><asp:RequiredFieldValidatorID="rfvUserPwd"
runat="server" ControlToValidate="txtUserPwd" ErrorMessage="Password is
required.">*</asp:RequiredFieldValidator></td>
When the text box is left blank, the asterisk shows up too far to the right
of the text box. The problem isn't really if there's only one text box to
validate but if you have 3 or 4 stacked on top of each other. If one text
box only has a required field validator, then my asterisks don't line up
vertically. It looks crude that way.
Bottom line is I need to know if it's possible using regular expressions to
also require the value. What can I add to this:
^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$
to make it required. I'm not great with regular expressions.
Thanks,
Keith