Form-validation – message

materix
Backer | 83
+
0
-

Can I stop Nette-forms from using client-side “required” html5-attribute for required fields, and only do server-side validation for required fields?

jeremy
Member | 54
+
+1
-

materix wrote:

Can I stop Nette-forms from using client-side “required” html5-attribute for required fields, and only do server-side validation for required fields?

I usually just use the novalidate attribute on the form element. This disables validation of any kind: required, email, etc.
After that you are free to use any form of custom validation you want.

Last edited by jeremy (2022-09-04 17:55)

materix
Backer | 83
+
0
-

Thanks for the reply.

Where do you set the novalidate-attribute?

jeremy
Member | 54
+
0
-

materix wrote:

Thanks for the reply.

Where do you set the novalidate-attribute?

Like so, simply inside the form tag:

<form novalidate>
...
</form>

If you are using the default renderer you can also use this:

$form->setHtmlAttribute('novalidate', 'true');

Last edited by jeremy (2022-09-04 19:07)