将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>
答案 0 :(得分:0)
我在研究类似的问题/错误时发现了这一点。我认为maskedinput的版本与jquery-1.9冲突。我在这里发现:https://github.com/angular-ui/angular-ui/issues/495不知道这对你有帮助,但是......