validasi yang dapat diandalkan di Laravel
$('#formid').validate({
rules: {
inservice_quota: "required",
inservice_jion_date: {
required: function () {
if ($('#idofpreviousfield').val() === 'Yes') {
return true;
} else {
return false;
}
},
},
inservice_posting_addr: {
required: function () {
if ($('#InserviceQuota').val() === 'Yes') {
return true;
} else {
return false;
}
},
},
inservice_establish_noc:{
required: function () {
if ($('#InserviceQuota').val() === 'Yes') {
return true;
} else {
return false;
}
},
},
inservice_establish_noc_date:{
required: function () {
if ($('#Noc').val() === 'Yes') {
return true;
} else {
return false;
}
},
},
inservice_dept_enquiry:{
required: function () {
if ($('#InserviceQuota').val() === 'Yes') {
return true;
} else {
return false;
}
},
}
},
messages: {
inservice_quota:{
required :"Please Select Inservice Quota"
},
inservice_jion_date:{
required :"Please select Date of Joining Permanent Service"
},
},
submitHandler: function (form) {
var action = "{{ route('Quota.store') }}";
$.ajax({
url: action,
data: $(form).serialize(),
type: 'post',
success: function (result) {
console.log(result.status);
if (result.status == "success") {
toastr.success(result.msg);
}
},
error: function (response) {
let data = response.responseJSON.errors;
if (data) {
$.each(data, function (index, jsonObject) {
$.each(jsonObject, function (key, val) {
console.log(val);
toastr.error(val);
});
return false;
});
}
}
});
}
});
ashish basuri