I have a web form to submit a new user details. In that for password field, a textbox is used.
Validation is required for that as ‘it shold contain min 8 characters with atleast one non-alphanumeric character’. I’m providing validation for it in web config file as:-
<membership defaultProvider="SQLMembershipProvider">
<providers>
<remove name="SQLMembershipProvider"/>
<add name="SQLMembershipProvider" connectionStringName="DAFEConnection" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" type="System.Web.Security.SqlMembershipProvider" applicationName="WBCPDA" requiresQuestionAndAnswer="false" enablePasswordReset="true" maxInvalidPasswordAttempts="4" passwordAttemptWindow="15" requiresUniqueEmail="true"/>
</providers>
</membership>
This validation is triggered on server side, i.e. when I click ‘submit’ button.
I WANT TO VALIDATE THE SAME AT CLIENT-SIDE, i.e. as soon as he enters a non-desired value in text-box.
PLZ help
The quickest way to do this would be using a Regular Expression Validator. See documentation here.
Kangkan’s suggestion is very good; not only the idea to use jQuery for this; but mostly the idea of using a regular expression to validate that the password is in the expected format.
Additional answer:
It’s difficult The quickest way to give you exact code that will work for your case since you didn’t provide markup; but you could do something similar to this :
And would be using a javascript function .Regular Expression Validator. See documentation here.