HTML5输入类型杀死了jQuery验证 [英] HTML5 input types kill jQuery validation
问题描述
jQuery验证插件会中断定义了HTML5类型的元素.
$(document).ready(function(){
$("#myform").validate()
});
...
<form id="myform">
<input id="email" email="true" />
</form>
...
在输入中添加html5属性 type ="email" 会导致验证失败.我要使用 type ="email" ,因为手机使用此属性可以默认情况下显示正确的键盘布局..
同时实现手机友好的键盘和jquery验证库的最佳方法是什么?
您可以在此处看到问题的示例.
您也许可以合并在代码中,虽然确实需要测试,但这似乎是正确的选择).
您也许还可以使用 HTML5必填字段(可能受支持) (未启用JavaScript的客户端)),但请参见此问题.>
The jQuery validation plugin breaks for elements that have a HTML5 type defined.
$(document).ready(function(){
$("#myform").validate()
});
...
<form id="myform">
<input id="email" email="true" />
</form>
...
Adding the html5 attribute type="email" to the input causes the validation to fail. I want to use type="email" because mobile phones use this attribute to display the proper keyboard layout by default.
What's the best way to achieve both mobile phone friendly keyboards + jquery Validation library?
You can see an example of the issue here.
You might be able to merge this pull request with the main trunk, if you're willing to maintain your own version of the plugin (the patch is quite small and, from a cursory look at the code, seems like the right thing to do, though it would certainly require testing).
You may also be able to fallback to just using the HTML5 required field (potentially supported by non-javascript-enabled clients), but see this issue.
这篇关于HTML5输入类型杀死了jQuery验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!