简体   繁体   English

javascript与html5中的表单验证

[英]form validation in javascript vs html5

During client-side form validation certain parts can be validated using html(using the required or type attribute in <input>). 在客户端表单验证期间,可以使用html(使用<input>中的requiredtype属性)来验证某些部分。 I can achive those same things using js. 我可以使用js达到相同的目的。 So, what parts of the form validation should be done in js and what parts can be left for html? 那么,表单验证的哪些部分应该在js中完成,哪些部分可以保留给html? Which one is more safe? 哪一个更安全?

HTML5 validation is convenient but it depends on your audience. HTML5验证很方便,但这取决于您的受众。 HTML5 validations are not supported by some older browsers (here is the list: http://caniuse.com/#feat=form-validation ). 一些较旧的浏览器不支持HTML5验证(列表如下: http : //caniuse.com/#feat=form-validation )。 Also I've noticed a Safari bug: the form doesn't validate (expected behavior) but the pop up error message doesn't display leaving the user unsure of the issue. 我还注意到了一个Safari错误:表单无法验证(预期行为),但是没有显示弹出错误消息,使用户不确定该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM