I have a form with two fields User ID and Email ID. I am trying to validate value of each field is already taken or not using same php file with jQuery remote validation.
But my confusion is how should be the remote file in my case (validate.php). How it can determine the fields.
My code looks like:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Validationt</title>
<script type="text/javascript">
$(document).ready(function(){
$("form").validate({
rules: {
userid: {
required: true,
remote: {
url: "validate.php",
type: "post",
}
}
emailid: {
required: true,
remote: {
url: "validate.php",
type: "post",
}
}
},
messages: {
userid: {
remote: jQuery.validator.format("userid {0} is already taken")
}
emailid: {
remote: jQuery.validator.format("emailid {0} is already taken")
}
}
});
});
</script
</head>
<body>
<form method="post" id="form" action="">
<input id="userid" name="userid" type="text" />
<input id="emailid" name="emailid" type="text" />
<input type="submit" name="submit" id="submit"/>
</form>
</body>
</html>
Any help ?