1

I have been reading about how to manipulate regex, and I do think I have the correct formula for my purpose, but I cannot seem to get it to work.

This is my code

$.validator.addMethod("pwcheck", function(value) {
    var regex = /^[a-zA-Z0-9]*$/;
    if (!regex.test(value)) {
        return false;
    }
});

I added this method to my password in the .validate({rules{}}); It is linked properly, but whatever I input in the text box I get the message I wrote in the .validate({messages{}}); the user should be only allowed to input letters and numbers, and seeing other methods posted on this site I tried to mimic and copy them, but it isn't working.

1 Answer 1

1
$.validator.addMethod("pwcheck", function(value) {
   return /^[A-Za-z0-9]*$/.test(value)
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.