Click here to Skip to main content
14,880,638 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I want to implement jquery validation for password using dynamic password policy. so we need to separate regex for alphanumeric, case sensitive, and special characters.


What I have tried:

I have done below code-

    $(function () {
            $("[id$=btn_changePwd]").click(function () {

<pre>if (Boolean.parse(validationSettings.IsAlphanumeric) && !$("[id$=txtNew]").val().trim().match(/^[a-zA-Z0-9]+$/)) {
                    $("[id$=lblMessage]").show();
                    $("[id$=txtNew]").focus();
                    return false;

                }
                else {
                    $("[id$=lblMessage]").hide();
                }

                if (Boolean.parse(validationSettings.IsCaseSensitive) && !$("[id$=txtNew]").val().trim().match(/^(?=.*[a-z])(?=.*[A-Z])/)) {
                    $("[id$=lblMessage]").show();
                    $("[id$=txtNew]").focus();
                    return false;
                }
                else {
                    $("[id$=lblMessage]").hide();
                }
                if (Boolean.parse(validationSettings.IsSpecialChars) && !$("[id$=txtNew]").val().trim().match(/^(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]/)) {
                    $("[id$=lblMessage]").show();
                    $("[id$=txtNew]").focus();
                    return false;
                }
                else {
                    $("[id$=lblMessage]").hide();
                }
if (password != confirmPassword) {
                    alert("Passwords do not match.");
                    return false;
                }
                return true;
            });

        });
Posted
Updated 5-Mar-17 19:00pm
v2
Comments
Patrice T 6-Mar-17 2:11am
   
And you have a question or a problem ?
suneel kumar gupta 6-Mar-17 6:44am
   
above code not working so I need solution of this issue.
Patrice T 6-Mar-17 7:03am
   
Can you define "not working" ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900