I have the following example:
I have 2 text fields country and city. For each field i want to check
with a remote validation if the city matches the country and vice
versa.
i made the following dummy html page
<html>
        <head>
                <script src="lib/jquery.js" type="text/javascript"></script>
                <script src="jquery.validate.js" 
type="text/javascript"></script>
                <script>
                jQuery.validator.addClassRules({
                country_city:{
                remote: {
            url  : 'http://long url/validate_country_city.cgi',
            type : 'post',
            data: {
                country: function() {
                    return $('input[name=country]').val();
                          },

                                city: function() {
                    return $('input[name=city]').val();
                          }

                }
       }
           }
        });
        $(document).ready(function() {
        $('form').validate();
        });
                </script>
        </head>
        <body>
        <form name ="kuku">
                Country:<input class="country_city" name="country" value=""><br>
                City <input class="country_city" name="city" value=""><br>
                <input type="submit">
        </form>
        </body>
</html>
now in the country i write austria and in the city i write washington.
I will have in both fields errors as washington is not in austria, so
i change to vienna. then the city line is cleaned of errors, but the
country line not. The problem is that the country validation should
also be triggered by changing the city.
Maybe i make errors in how using the validator.
Is there another way to solve the problem ?

Thanks,
David

Reply via email to