0

将 jquery.maskedinput 应用到使用 jquery.validate 验证的输入时,jquery.validate 错误地将输入解释为需要关注输入元素。我怎样才能防止这种影响?

谢谢

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <title>jQuery validation with mask</title>

        <script src="http://code.jquery.com/jquery-1.7.2.js"></script> 
        <script src="http://cloud.github.com/downloads/digitalBush/jquery.maskedinput/jquery.maskedinput-1.3.js" type="text/javascript"></script>

        <!-- Using jquery.validate 1.9.0 -->
        <script src="jquery.validate.js" type="text/javascript"></script>
        <script src="additional-methods.js" type="text/javascript"></script>

        <script type="text/javascript">
            $(function(){
                var validate = $("#myForm").validate({
                    rules: {phone:'phoneUS'},
                    messages: {phone:'Enter a valid phone number'},
                    submitHandler: function(form) {alert('submit');}
                });

                $("#phone").mask("(999) 999-9999");

            });
        </script>
    </head>
    <body>
        <form id="myForm" method="get" action="">
            <label for="phone">Phone</label>
            <input id="phone" name="phone" type='text' />
            <input type="submit" value="Submit" class="submit" />
        </form>
    </body>
</html>
4

1 回答 1

0

我只是在研究类似的问题/错误时发现了这一点。我认为该版本的 maskedinput 与 jquery-1.9 冲突。我在这里发现: https ://github.com/angular-ui/angular-ui/issues/495不知道这是否对您有帮助,但是..

于 2013-05-24T14:43:05.047 回答