$(document).ready(function() {
$('#formid').validate({
rules: {
fname : "required",
mname : "required",
},
messages: {
fname: "Please enter father name",
mname: "Please enter mother name",
},
submitHandler: function(form) {
var action="{{ route('personalinformation.store') }}";
$.ajax({
url : action,
data:$(form).serialize(),
type : 'post',
success : function(result){
// alert(result.url);
if(result.status === "success"){
toastr.success(result.msg); // toastr used
setTimeout(function () {
window.location.href = result.url;
}, 2000)
}
},
error:function (response) {
let data = response.responseJSON.errors;
if (data) {
$.each(data, function(index, jsonObject) {
$.each(jsonObject, function(key, val) {
toastr.error(val); // this wil show the error message
});
return false;
});
}
}
});
}
});
});