jQuery validate bug with required validation on IE10 in compatibility mode to IE7/IE8

牧云@^-^@ 提交于 2019-11-28 12:00:03

问题


there is a Confirmed bug in IE10 compatibility mode that won't be fixed for IE10:

In IE10 in compatibility to IE8
$element.get(0).getAttribute("required") returns "" when the required attribute is missing, this causes ALL fields to be required

In IE10 in compatibility to IE7
$element.get(0).getAttribute("required") returns null in all cases.
so you can't use required as an attribute on the element

The plugin Author doesn't plan to handle compatibility views as users shouldn't encounter it, but developers that just want to check something in old IE might want to


回答1:


In IE10 in compatibility to IE8
element.attributes["required"] is null if the required attribute is missing

In IE10 in compatibility to IE7
element.attributes["required"].value returns "-1" if required attribute exists and "null" otherwise

so updated my fork to the jQuery validate plugin for this fix all details here https://github.com/avipinto/jquery-validation/commit/a22d4c37c3047199bf17a4943e3be352d88d8158




回答2:


I changed mine to call

$element.get(0).hasAttribute("required")

before checking the value with getAttribute()



来源:https://stackoverflow.com/questions/18080731/jquery-validate-bug-with-required-validation-on-ie10-in-compatibility-mode-to-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!