[jQuery] Validation
[jQuery] Validation
I have seriously been fighting this issue for hours. I would
appreciate some advice when someone gets a chance.
I am wanting to check my database to determine if this user already
exists. I thought I could just add the method to the validation.
Evidently I'm doing something wrong. Here is the code.
<script type="text/javascript">
$(document).ready(function(){
var checkName = (function(value){
var dataString = '?mode=checkUser&username=' + username.val();
$.ajax({
type: "GET",
url: "user_formsubmit.php" + dataString,
success: function(html){
if(html == "True")
{
return true;
}
else
{
return false;
}
}
});
});
$.validator.addMethod("checkName", function(value, element){
return checkName(value);
}, "This user name already exists.");
$("#user_form").validate({
rules: {
userName: {
required: true,
minlength: 8,
checkName: false
},