+ 3
what lacks on html5 "required" and javascript validation form? and better use which one
8 Antworten
+ 6
That’s a good idea. Yes, I would recommend that instead.
+ 6
You could use JavaScript to detect whether or not the browser supports the required attribute, if it doesn’t, then enable the JS form validation.
+ 6
var supported = "required" in element;
if(!supported) {
enableFormValidation();
}
+ 5
Downsides of HTML ‘required’: some browsers may not support HTML5 yet.
Downsides of JavaScript validation: some users may have JavaScript disabled in their browser settings.
I would recommend the HTML ‘required’ attribute, because it’s much easier.
+ 4
if I use both, is it better for example if the browser does not support html5, it will be replaced by JavaScript or vice versa
+ 4
and if the browser supports both whether if the user sends a blank form it will display two warnings
+ 4
how is that?
+ 4
Thanks 👍