I have a form with a remote validation field. My Javascript is as bellow:
$("#myform").validate({
rules: {
mainfield: {
remote:{
url: "checksnote.php",
type: "POST",
data: {
mainfield: function() {
return $("#mainfield").summernote('isEmpty');
}
}
}
}
},
messages:{
mainfield: {
remote: "This field is required",
//minlength: "Minimum Length is 10"
}
},
submitHandler: function(form) {
alert("Successfully submittable");
console.log("Successfully submittable");
form.submit();
}
});
Problem is I am unable to get any response at all. Both the remote requests show valid but no ajax request is seen in the browser. Mainfield is summernote textarea. All other validations are working perfectly fine. Any idea why remote is not even sending a request?
Update- I also tried to add Method did not work. Thats why I tried remote instead. Either one is fine if works for me. This is my method code. Browser is not showing any error.
$.validator.addMethod('sumnoteempty', function(value,element){
//return false;
if(element.summernote('isEmpty')){
console.log("In summernote validation!");
return false;
}
else {
return true;
}
}, "Must enter summernote content");
Rules are as bellow:
rules: {
mainfield: {
sumnoteempty: true
}
},
message:{
sumnoteempty: "Field can not be empty"
}
I dont understand what I am doing wrong here. It does not even show message in console. All other validation logic is working great. Except remote and add method.
remoteto evaluate that the field is "required"? You do not need the server to tell you when a field is empty. This approach makes absolutely no sense. Typically,remoteis used to send the field's data to the server to compare it to something that can only be learned on the server... like when a username is already taken. You wouldn't send "nothing" to the server when you'd already know it's nothing before you send it.name="mainfield"an actual<textarea></textarea>element? The Validate plugin does not work ondivelements or anything else that is not a data input for a<form>. Inspect your DOM to be sure.