Я новичок для проверки плагина в jquery … Я пытаюсь использовать submitHandler для отправки формы после проверки. Но я получаю сообщение об ошибке..TypeError: $ .validator.methods [метод] не определен … Я прошел через другие ответы, но не нашел решения. я получаю ошибку при нажатии кнопки отправки.
Ниже мой HTML-код
<html>
<head>
<title></title>
<script type="text/javascript" src="../public/assets/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../public/assets/js/jquery.validate.js"></script>
<script type="text/javascript" src="../public/assets/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="../public/assets/js/personal.js"></script>
</head>
<body>
<form id="personal_form" method="post" action="">
Registeration ID:<input type="text" id="regid" name="regid" value="<?php echo $regid?>" readonly><br>
First Name:<input type="text" name="first_name" id="first_name" value="<?php echo $fname;?>"><br>
Last Name:<input type="text" name="last_name" id="last_name" value="<?php echo $lname;?>"><br>
Gender:<div style="margin:-17px;padding-left:81px">
<?php for($i=0;$i<count($gender);$i++):?>
<input type="radio" id="gender" name="gender[]" value="<?php echo $gender[$i]['slno'];?>"> <?php echo $gender[$i]['gender']?>
<?php endfor;?>
</div>
<br>
Care of:<div style="margin:-19px;padding-left:81px;">
<?php for($i=0;$i<count($careof);$i++):?>
<input type="radio" id="careof" name="careof[]" value="<?php echo $careof[$i]['slno']?>"> <?php echo $careof[$i]['care_of'];?>
<?php endfor;?>
</div><br>
Native Place:<input type="text" name="native_place" id="native_place"><br>
Date of Enrollment:<select id="enroll_year" name="enroll_year">
<option value="0">YEAR</option>
<?php for($i=1947;$i<=$date;$i++):?>
<option value="<?php echo $i?>"><?php echo $i;?></option>
<?php endfor;?>
</select>
<select id="enroll_month" name="enroll_month">
<option value="0">MONTH</option>
<?php for($i=1;$i<=12;$i++):?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php endfor;?>
</select>
<select id="enroll_date" name="enroll_date">
<option value="0">DATE</option>
<?php for($i=1;$i<=31;$i++):?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php endfor;?>
</select><br>
Enrollment No:<input type="text" name="enroll_no" id="enroll_no" value="<?php echo $data[0]['enroll_no'];?>" ><br>
Court of Practice:<input type="text" name="court_practice" id="court_practice" value="<?php echo $data[0]['court_practice'];?> "><br>
Field of Practice:<input type="text" name="field_practice" id="field_practice" value="<?php echo $data[0]['field_practice'];?>"><br>
Name of the Bar Association:<input type="text" name="name_bar_assoc" id="name_bar_assoc" value="<?php echo $data[0]['bar_council_name']; ?>"><br>
Designation:<input type="text" name="designation" id="designation"><br>
Date of Birth:<select id="dob_year" name="dob_year">
<option value="0">YEAR</option>
<?php for($i=1947;$i<=$date;$i++):?>
<option value="<?php echo $i?>"><?php echo $i;?></option>
<?php endfor;?>
</select>
<select id="dob_month" name="dob_month">
<option value="0">MONTH</option>
<?php for($i=1;$i<=12;$i++):?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php endfor;?>
</select>
<select id="dob_date" name="dob_date">
<option value="0">DATE</option>
<?php for($i=1;$i<=31;$i++):?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php endfor;?>
</select><br>
Blood Group:<input type="text" name="blood_group" id="blood_group"><br>
Office Address:<input type="text" name="office_addr" id="office_addr"><br>
Residence Address:<input type="text" name="residence_addr" id="residence_addr" value="<?php echo $data[0]['addr'];?>"><br>
Mobile No:<input type="text" name="mobile_number" id="mobile_number" value="<?php echo $data[0]['mobile_no'];?>"><br>
Office No:<input type="text" name="office_number" id="office_number"><br>
Residence No:<input type="text" name="residence_number" id="residence_number"><br>
Email ID:<input type="text" name="email_id" id="email_id" value="<?php echo $data[0]['email_id'];?>"><br>
Photo:<input type="file" name="photo" id="photo"><br>
<div id="photo"></div>
<input type="submit" id="submit_personal" value="Submit">
<div id="response"></div>
</form>
</body>
</html>
Personal.js выглядит следующим образом
$(document).ready(function(){
$("#personal_form").validate({
rules:{
first_name:{
required:true,
minlength:5,
maxlength:32
},
last_name:{
required:true,
minlength:5,
maxlength:32
},
'gender[]':{
required:true,
},
'careof[]':{
required:true,
},
native_place:{
required:true
},
enroll_year:{
selectenrollyear:true
},
enroll_month:{
selectenrollmonth:true
},
enroll_date:{
selectenrolldate:true
},
enroll_no:
{
required:true
},
court_practice:
{
required:true
},
field_practice:
{
required:true
},
name_bar_assoc:
{
required:true
},
designation:
{
required:true
},
dob_year:
{
selectdobyear:true
},
dob_month:
{
selectdobmonth:true
},
dob_date:
{
selectdobdate:true
},
blood_group:
{
required:true
},
office_addr:
{
required:true
},
residence_addr:
{
required:true
},
mobile_number:
{
required:true,
mobilecheck:true
},
office_number:
{
required:true
},
residence_number:
{
required:true
},
email_id:
{
required:true,
email:true
},
photo:
{
required:true,
accept: "image/*"}
},
messages:{
first_name:{
minlength: "First name should be atleast 5 characters",
maxlength: "First name should not be more than 32 characters"},
last_name:{
minlength: "Last name should be atleast 5 characters",
maxlength: "Last name should not be more than 32 characters"},
gender:{
required:"Please select a gender"},
careof:{
required:"Please select careof"},
native_place:{
required:"Please enter your native place"},
enroll_no:
{
required:"Please enter your enrollment number"},
court_practice:
{
required:"Please enter the court of practice"},
filed_practice:
{
required:"Please enter the field of practice"},
name_bar_assoc:
{
required:"Please enter the name of bar association"},
designation:
{
required:"Please enter your designation"},
blood_group:
{
required:"Please enter your blood group"},
office_addr:
{
required:"Please fill your office address seperated by comma"},
residence_addr:
{
required:"Please fill your residence address seperated by comma"},
mobile_number:
{
required:"Please fill your mobile number"},
office_number:
{
required:"Please fill your office number"},
residence_number:
{
required:"Please fill your residence number"},
email_id:
{
required:"Please fill your email id",
email:"The email should be in the form [email protected]"},
photo:
{
required:"Please upload your photo",
accept:"Image files only"}
},
submitHandler:function(form){
$.ajax({
type: "POST",
url: "assets/js/personal.php",
data: form.serialize(),
success:function(data){
console.log(data);
}
});
return false;
}
});
jQuery.validator.addMethod('selectenrollyear',function (value) {
return (value != 0);
}, "Select the enrollment year");
jQuery.validator.addMethod('selectenrollmonth',function (value) {
return (value != 0);
}, "Select the enrollment month");
jQuery.validator.addMethod('selectenrolldate',function (value) {
return (value != 0);
}, "Select the enrollment date");
jQuery.validator.addMethod('selectdobyear',function (value) {
return (value != 0);
},"Select the year");
jQuery.validator.addMethod('selectdobmonth',function (value) {
return (value != 0);
},"Select the month");
jQuery.validator.addMethod('selectdobdate',function (value) {
return (value != 0);
},"Select the date");
jQuery.validator.addMethod('mobilecheck',function (value){
if(value.length != 9)
return value;
},"Mobile number should be of 10 digits");
});Personal .php is as follows
<?php
echo $_POST["regid"];
?>
Спасибо
Задача ещё не решена.
Других решений пока нет …