-
-
Save thomasv314/4196532 to your computer and use it in GitHub Desktop.
form validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
jQuery.validator.addMethod("password", function(value, element) { | |
var isValid = value.length >= 6 && /\d/.test(value) && /[a-z]/i.test(value); | |
return isValid; | |
}, "Password must be at least 8 characters and must contain one number and one character."); | |
jQuery.validator.addMethod("inUse", function(value, element){ | |
var email_exists = false; | |
$.ajax({ | |
type: 'POST', | |
url: "checkEmail", | |
data: value, | |
success: function(response) { | |
email_exists = JSON.parse(response.responseText); | |
}, | |
dataType: dataType | |
}); | |
return email_exists; | |
}, "This email is already in use."); | |
$("#regie").validate({ | |
rules: { | |
password: { | |
password: true, | |
required: true | |
}, | |
confirmPass: { | |
equalTo: "#password" | |
}, | |
email: { | |
inUse: true, | |
required: true, | |
email: true | |
}, | |
confirmEmail: { | |
equalTo: "#email" | |
}, | |
fName: "required", | |
lName: "required" | |
}, | |
messages: { | |
confirmEmail: { | |
equalTo: "Please enter the same email." | |
}, | |
confirmPass: { | |
equalTo: "Please enter the same password." | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment