Basically, I need to test if the sub-domain exists or not so I added a method uniqueSubdomain to my jQuery Validate rules:
$.validator.addMethod("uniqueSubdomain", function(value, element) {
$.ajax({
type: "POST",
url: "ajax.php",
data: 'subdomain='+ value,
cache: false,
success: function(msg)
{
alert(msg);
// if the subdomain exists, it returns a string "true"
if(msg == "true"){
return false; // already exists
}else{
return true; // subdomain is free to use
}
}
})}, "sub-domain already exists!");
And in the rules :
subdomain: {
required: true,
uniqueSubdomain: true
},
But it seem that it only displays sub-domain already exists! Even if it doesn't exist! Any help with this, Thanks!
'&subdomain='+valuedata: {subdomain: value},true. Post your php code to your question