This is my Script :
<script>
$(function() {
$("#yourFormId").validate({
rules: {
mobile: {
required: true,
mobile: true,
remote: {
url: "mobileajax.php",
type: "get"
}
},
},
messages: {
mobile: {
required: "Please enter a valid mobile address",
minlength: "Please enter proper mobile",
remote:function(){
$('.result').html('mobile Already used.').addClass('messageboxerror').fadeOut(5000);
},
}
},
errorPlacement: function (error, element) {
element.attr("placeholder", error.text());
},
});
});
</script>
This is Html file:
<form id="yourFormId" action="try.php" method="post">
mobile No.<div class="result"></div>
<input id="mobile" type="text" name="mobile" />
<input type="submit" value="submit">
Thsi is mobileajax.php
<?php
require "connect/connectOpen.php";
$sql = "select mobile from tbl_user";
$rsd = mysql_query($sql);
$data = mysql_fetch_array($rsd);
$registeredEmail = array($data[0]);
$requestedEmail = $_REQUEST['mobile'];
if( in_array($requestedEmail, $registeredEmail) ){
echo 'false';
} else {
echo 'true';
}
?>
Same things i was using for email match exist its works, but for mobile its did not work.not validate moile number from database, only same code works with email match.