我有一个Web应用程序,它经常使用HTML5 required属性.但是Safari和ie 8/9不支持此属性.是否有一个jQuery插件会强制在不兼容的浏览器上的行为?
解决方法
这没有任何插件(仅限JQuery):
<script>
// fix for IE < 11
if ($("<input />").prop("required") === undefined) {
$(document).on("submit",function(e) {
$(this)
.find("input,select,textarea")
.filter("[required]")
.filter(function() { return this.value == ''; })
.each(function() {
e.preventDefault();
$(this).css({ "border-color":"red" });
alert( $(this).prev('label').html() + " is required!");
});
});
}
</script>