不支持的浏览器上的html5必需属性

ste*_*0nz 6 jquery html5 required

我有一个Web应用程序,它required经常使用HTML5 属性.但是Safari和ie 8/9不支持此属性.是否有一个jQuery插件会强制不兼容的浏览器上的行为?

sno*_*rri 7

这没有任何插件(仅限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>
Run Code Online (Sandbox Code Playgroud)


ste*_*0nz -1

发现了一个非常通用且轻量级(曾经缩小过)的引擎,可以跨浏览器工作,包括 ie8!

http://posabsolute.github.io/jQuery-Validation-Engine/