Html 表单html标签中Angular指令novalidate的用法是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27541080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the usage of Angular directive novalidate in a form html tag
提问by ng-R
I wanted to understand the meaning of novalidate directive usage in form tag, especially when used to validate the form.
我想了解表单标签中 novalidate 指令用法的含义,尤其是在用于验证表单时。
Thanks
谢谢
回答by Aniket Sinha
It prevents the browser's native validation to kick in i.e form data will not be validated upon submission. Examples include input where type='email'
它可以防止浏览器的本地验证启动,即表单数据在提交时不会被验证。示例包括输入,其中type='email'
Note that it is not Angular's directive. It is HTML 5 attribute. Read more about it here
请注意,这不是 Angular 的指令。它是 HTML 5 属性。在此处阅读更多相关信息
回答by kumareloaded
novalidateattribute is used to disable browser's native form validation.
novalidate属性用于禁用浏览器的原生表单验证。
You can use it when you need do your own AngularJS custom validation.
当您需要进行自己的 AngularJS 自定义验证时,您可以使用它。
回答by fgul
You can use the same ones used by the HTML 5 specification in Angular,so you can add the novalidateattribute to the formelement, which tells the browser notto use its native validation. Because different browsers have different implementation validations. Since Angular get validation itself, the browser don't need to do validation implementation.
您可以使用 Angular 中 HTML 5 规范所使用的相同的那些,因此您可以将novalidate属性添加到表单元素,它告诉浏览器不要使用其原生验证。因为不同的浏览器有不同的实现验证。由于 Angular 本身得到验证,浏览器不需要做验证实现。