Skip to content

Fixed synchronised remote calls. #529

Closed
wants to merge 1 commit into from

3 participants

@11mb
11mb commented Oct 15, 2012

Fix as described in Issue #517.

  • Removed line 385 this.errorList = [];

When using async=false remote-validation errormessages of the fields
above (in html) won't show up.

@william-nedbase william-nedbase Fixed synchronised remote calls.
Fix as described in Issue #517.
- Removed line 385 this.errorList = [];

When using async=false remote-validation errormessages of the fields
above (in html) won't show up.
cc42ffc
@jzaefferer
Owner

Don't ever use async=false in production, that's just wrong. I'll keep this open for now to figure out what problem you're actually trying to solve though.

@11mb
11mb commented Oct 15, 2012
@11mb
11mb commented Oct 16, 2012

The reason why I use async=false is because of the following bug in the async=true functionallity.

When having a field with a remote rule with a prefilled correct value in a form with the validater. The validater won't submit my submitbutton when I don't clicked the field with the remote rule first. In most forms I really want to know what button is clicked..

Here is a sample form with the problem:

  • try to submit the form with or without clicking the input field first
  • Tested in firefox and chrome
  • jQuery Validation Plugin - v1.10.0 - 9/7/2012

<?php
if(sizeof($_POST) > 0) {
    if(isset($_POST['next'])) {
        echo 'you submitted the form after clicking the field with remote rule';
    } else {
        echo 'you submitted the form without clicking the field with remote rule';
    }
} ?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>title</title>
        <script src="jquery-1.7.1.min.js"></script>
        <script src="jquery.validate.js"></script>
    </head>
    <body>
        <script type="text/javascript">
                $(document).ready(function() {
                    window.validater = $("#signUpForm").validate({
                        rules: {
                            "remoteinput": {
                                remote: "/remote.php"
                            }
                        },
                        messages: {
                            "remoteinput": {
                                remote: "Errormessage for remoterule"
                            }
                        }
                    });
                });
        </script>
        <form name="signUpForm" method="POST" id="signUpForm">
            <label for="remoteinput">Field with remote rule </label>
            <input type="text" name="remoteinput" value="correct_value" style="" title="" class=" " id="remoteinput">
            <button value="Verder" name="next" class="submit" type="Submit" id="next">Next</button>
        </form>
    </body>
</html>

Content of remote.php:


<?php
echo 'true';
?>
@jzaefferer
Owner

Thanks for the code, I could reproduce the issue with that. I've logged #658 for that issue.

@jzaefferer jzaefferer closed this Feb 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.