We have this requirement for our users to use the following format as their password:
First Initial of first name + first initial of Last Name + date of birth in the format of MMDDYYYY. (For example, John Doe born January 1, 1900 will be, JD01011900
Now we have been asked to enforce it since users were using it recklessly to put whatever information they like on the textbox.
We have been asked to ensure that the first letter user enters is 2 upper case letters, followed by 10-digit month, day and year. What I was trying to accomplish with the code above is to:
1, force the user to enter 2 upper case letters. For instance, jd would become JD then followed 10 digits so we get JD01011900.
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtUserID" SetFocusOnError="true" Display="Dynamic" ErrorMessage="Format is wrong, must be in the format of JD01011900"
ForeColor="Red" ValidationExpression="^[A-Za-z]{2}\d{10}$">
</asp:RegularExpressionValidator>
What I was trying to accomplish with the code above is to:
1, force the user to enter 2 upper case letters. For instance, jd would become JD then followed 10 digits so we get JD01011900.
2, The second thing I am trying to accomplish with this regex is to keep user on that same textbox until user enters correct format. To do to so, I added SetFocusOnError.
Nothing seems to be working.
Is there a better way to handle this from VB?
As always, many thanks for your assistance in advance.