Changes the error messages from remotely.Please help me.
Here is the sample code in jquery.
<script id="demo" type="text/javascript">
$(document).ready(function() {
// validate signup form on keyup and submit
var validator = $("#signupform").validate({
rules: {
mobile:
{
required: true,
minlength: 10,
maxlength: 12,
remote:"mobile.php"
}
},
messages: {
mobile: {
minlength: "Mobile No. must be 10 digits",
maxlength: "Mobile No. must be 10 digits",
required: " Please enter Mobile Number",
remote: "Mobile No. already exists"
}
},
// the errorPlacement has to take the table layout into account
errorPlacement: function(error, element) {
error.prependTo( element.parent().next() );
},
// specifying a submitHandler prevents the default submit, good for the demo
// set this class to error-labels to indicate valid fields
success: function(label) {
// set as text for IE
label.html(" ").addClass("checked");
}
});
});
</script>
And remote php
<?php
include("dbconnect.php");
$mobile=$_REQUEST["mobile"];
$sql = "SELECT * FROM user_info where contact_no='$mobile'";
$result = mysql_query($sql,$conn);
$string = $mobile;
if(mysql_num_rows($result))
{
echo 'false';
}
else if(($string[0] == 0)||($string[0] == 1)||($string[0] == 2)||($string[0] == 3)||($string[0] == 4)||($string[0] == 5)||($string[0] == 6))
{
echo 'false';
}
else
{
echo 'true';
}
?>
In this php we are send only the true and flase.But i need the error messages. Remote error message pass form php script to the jquery.