0

在我的 HTML 页面中,我使用Live Validation 库

然而,我的问题是当我输入正确的值时,库显示“不匹配!” 当我清除所有输入时,它会正确验证。这是我的代码示例:

<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>

这里出了什么问题?

4

1 回答 1

0

我根据您的代码制作了这个示例……顺便说一句,它正在工作:

    <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>

在我的本地主机上测试;我切换了javascript的顺序。

萨卢多斯 ;)

于 2013-03-26T13:08:09.353 回答