This is how I am validating my form fields using jquery
$(document).ready(function () {
$(function() {
$("form[name='cont']").validate({
// Specify validation rules
rules: {
full_name: "required",
address: "required",
collage: "required",
grade: "required",
percentage: "required",
student_mobile:{
required: true,
minlength:10,
remote: {
url: "submit.php",
type: "post"
},
},
parent_mobile:{
required: true,
minlength:10,
},
},
// Specify validation error messages
messages: {
full_name: "Please enter your full name",
address: "Please enter your address",
collage: "Please enter your collagel name",
grade: "Please select grade,
percentage: "Please enter your percentage",
student_mobile:{
required:"Please enter your mobile number",
minlength: "Mobile number must be of 10 digits",
remote: "Mobile number is already in use!"
},
parent_mobile:{
required:"Please enter your mobile number",
minlength: "Mobile number must be of 10 digits"
},
},
submitHandler: function(form) {
send();
}
});
});
});
This is my submit.php file where I am trying to compare mobile number
<?php
$conn = mysqli_connect("localhost", "root", ""); // Establishing Connection with Server..
$db = mysqli_select_db($conn,"new"); // Selecting Database
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_POST['submit'])) {
$student_mobile = $_POST['student_mobile'];
if( $student_mobile !=''){
$check_mobile = mysqli_query($conn,"SELECT student_mobile FROM univ
WHERE student_mobile =".$student_mobile);
$res = mysqli_fetch_row($check_mobile);
}
$num_rows = count($res);
if( $num_rows > 0 ){
echo 'false';
} else {
//insert query here
}
}
- My other validations are working fine but validation for mobile is not
Where I am going wrong? I am confused , please help me