Search code examples
javascriptjquerylivevalidation

Live validation in jQuery?


In my HTML page I use the Live Validation library

My problem however is when I input a correct value, the library shows 'Does not match!' and when I clear all input, it validates correctly. This is my code example:

<script type="text/javascript" src="resources/jquery/livevalidation.js"></script>

<p>
        <label for="password">Password</label>
        <form:password id="password" path="password" tabindex="4" />
    </p>
    <p>
        <label for="password">Confirm Password</label>
        <form:password id="conformPassword" path="conformPassword" tabindex="5" />
    </p>
-----
    <script>
     $(document).ready(function(){
         ValidCaptcha();
     });
</script>
<script type="text/javascript">

    function ValidCaptcha() {
        var password1 = new LiveValidation('conformPassword');
        password1.add( Validate.Confirmation, { match: 'password' } );
    }
</script>

What goes wrong here?


Solution

  • I made this example based on your code....it's working btw:

        <html>
        <head>
    
        <script type="text/javascript" src="http://livevalidation.com/javascripts/src/1.3/livevalidation_standalone.compressed.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    
        <script type="text/javascript">
            function ValidCaptcha() {
                var password1 = new LiveValidation('conformPassword');
                password1.add( Validate.Confirmation, { match: 'password' } );
            }
            $(document).ready(function() {
              ValidCaptcha();
    
            });
        </script>
        </head>
        <body >
            <p>
                <label for="password">Password</label>
                <input type="password" id="password"  tabindex="4" />
            </p>
            <p>
                <label for="password">Confirm Password</label>
                <input type="password" id="conformPassword" tabindex="5" />
    
            </p>
        -----
    
    
        </body>
    
        </html>
    

    Tested on my localhost; i switch the order of the javascript.

    Saludos ;)