简体   繁体   English

禁用HTML5弹出表单验证消息

[英]Disabling HTML5 popup form validation messages

Let's say that i have in my form: 假设我有自己的表格:

{{ Form::email('fieldname', null, array()) }}

I fill this input as following : 我填写此输入如下:

thisisntanemailadress

After clicking on the submit button, a popup appears and says that this is not a valid email address , which prevents my form to get submitted. 单击提交按钮后,将显示一个弹出窗口,提示您这不是有效的电子邮件地址 ,这阻止了我的表单被提交。

How can i disable/configure all popup messages like that, except using Form::text() ? 除了使用Form::text()之外,我如何禁用/配置所有此类弹出消息?

This isn't caused by Laravel. 这不是Laravel造成的。 It's actually the browser attempting to validating the input fields value before allowing the user to submit the form. 实际上,浏览器实际上是在允许用户提交表单之前尝试验证输入字段的值。 This is triggered when you use a HTML5 input type, these include email , url , number , tel , date , and several others. 当您使用HTML5输入类型(包括emailurlnumberteldate和其他几种)时,将触发此事件。

The Form helper method you are using will generate the following HTML: 您正在使用的Form helper方法将生成以下HTML:

<input type="email" name="fieldname">

Most modern browsers will see the type="email" and attempt to validate any input before allowing you to submit the form. 大多数现代的浏览器都会看到type="email"并在允许您提交表单之前尝试验证任何输入。

If you don't want the browser to validate a specific field you can add the novalidate attribute to that fields input tag. 如果您不希望浏览器验证特定字段,则可以将novalidate属性添加到该字段输入标签。 For the form helper method you are using this can be done via the third parameter. 对于表单帮助器方法,可以通过第三个参数来使用。

{{ Form::email('fieldname', null, array('novalidate'=> 'novalidate')) }}

Alternatively you can disable browser validation for an entire form by adding the novalidate attribute to the Form tag. 另外,您可以通过将novalidate属性添加到Form标记来禁用整个表单的浏览器验证。

<form method="" action="" novalidate> ... </form>

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

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