0

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" > 
2
  • 1
    if you're going to do validation after form submits, that wouldn't make any sense then, what is there left to validate if form submits? maybe you didn't express yourself as you wanted, can you re-phrase Commented Mar 15, 2010 at 13:07
  • I think he means "on form submission" so that this specific input field only gets validated when somebody submits the form but if the remote validation fails the submit isn't executed Commented Mar 16, 2010 at 8:57

3 Answers 3

1

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");
    }
});
Sign up to request clarification or add additional context in comments.

Comments

1

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,
...
})

Comments

0
<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".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.