Reputation: 1251
Instead of verifying the value after each change, I would like my remote call to be invoked only after form submission.. Is this possible?
<input type="text" remote="validate_url.php" >
Upvotes: 0
Views: 3418
Reputation: 2005
check http://docs.jquery.com/Plugins/Validation/validate
if you want to validate only on submission, you can disable other events:
$("#form").validate({
onsubmit: true,
onkeyup: false,
onclick: false,
onfocusout: false,
...
})
Upvotes: 1
Reputation: 1251
<input type="text" remote="validate_url.php" id="place" name="place">
And inside the JQuery page load, I added the following:
$().ready(function() {
$("#form-id").validate({
onkeyup: false,
messages: {
place: {
required: "Please enter Place",
remote: jQuery.format("Please enter a valid Place or select one form the List")
}
}
});
});
Here I am trying to achieve the following: (1) User can either enter a Valid Place or (2) Choose one place from the List.
(when started typing the autosuggestion will list the matched Places). Now user may continue typing or select one form the list. If the user going to select one from list, the "controll" lost from the "text box" and the "remote" validation starts & returns error before the user selected the valid Place Name..
Actually I need to invoke the remote validation when the "control is out of the text box and autosuggestion list".. The autosuggestion values are inside a class "autosuggestion".
Upvotes: 0
Reputation: 54605
Did you try if something like this works? Set the remote field to ignore and validate it manually when the form is submitted.
$("#yourFormSelector").validate({
...
ignore: 'input[remote]',
submitHandler: function(form) {
if($(form).validate().element("input[remote]"))
form.submit();
else
alert("Nope. Remote failed");
}
});
Upvotes: 1