我意识到HTML5元素在IE上不起作用。诸如所需占位符之类的元素不适用于IE。我找到了一个javascript来使占位符工作,但我想问一下是否有任何javascript编码使得必需的属性也能正常工作?
干杯!
我的代码:
<input required="required" type="password" name="password" id="password" class="regfields"/>
提前致谢
答案 0 :(得分:0)
添加此js refrence:
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
试试这个:
<form id="myform">
<script type="text/javascript">
jQuery.validator.setDefaults({
debug: true,
success: "valid"
}); ;
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#myform").validate({
rules: {
field: "required"
}
});
});
</script>
<label for="field">
Required:
</label>
<input class="left" id="field" name="field" />
<br />
<input type="submit" value="Validate!" />
</form>
答案 1 :(得分:0)
你可以在这里找到一些有用的polyfills:https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills。即使在IE中,FORM polyfills也会为您提供HTML5 FORM设施。也许这就是你所需要的:http://www.useragentman.com/blog/2010/07/27/cross-browser-html5-forms-using-modernizr-webforms2-and-html5widgets/