标签:style blog color java strong ar for div log
这些东西都要放在form里写用submit button提交才可以作用
required属性
1 <form> 2 <input type="text" name="username"/> 3 <input type="submit" /> 4 </form> 5 <script type="text/javascript" src="jquery.js"></script> 6 <script type="text/javascript"> 7 var isUsernameRequired = document.forms[0].elements[‘username‘].required; 8 alert(isUsernameRequired); //字段是否有required检验 9 10 var isRequiredSupport = ‘required‘ in document.createElement(‘input‘); 11 alert(isRequiredSupport); //浏览器是否支持验证 12 </script>
email,url,chrome支持的不好
数值范围也支持地不好
pattern可以,其检测有效性方式和required一样
标签:style blog color java strong ar for div log
原文地址:http://www.cnblogs.com/cjy1993/p/3951628.html