I am new to jquery.. as form validation i am using the following form validation code..
just i added the remote method to check the email existance.. but it always saying the email is "already exist"
Here is the snippet of the code...
<script>
$(document).ready(function(){
$("#f2").validate({
debug: false,
rules: {
email: {
required:true,
email:true,
remote:'checkemail.php'
},
comments: {
required:true
}
},
messages:
{
email:{
required:"Please enter valid email",
remote:"Already Exist"
}
}});
});
</script>
Here is the form code..
<form name="f2" id="f2" method="post" action="">
<div>
<label >Email</label>
<input type="text" name="email">
</div>
</form>
Here is the checkemail.php code..
<?php
$email=$_GET['email'];
$query="select email from emails where email='$email'";
$res= mysql_query($query);
$cou= mysql_num_rows($res);
if($cou>0)
{
echo "true";
}
else{
echo "false";
}
?>
Update
i missed the db connection.. After putting the db connection in checkemail.php file, the remote method is not showing any message.. and form is submitting without checking the email is already exist why?
why the form behaving like this? Any idea..
Any suggestions are welcome...