0
How to create a form in HTML and not allow users to submit unless they fill it correctly?
Html form
3 Réponses
0
You can disable the submit button by adding disabled attribute to the button tag by js if the form is invalid.
0
depend on what defined correct.
if correct means not empty, we can add required attribute
if we need it to be at certain length of string add minlength and maxlength
if its a number we have min and max
and the big gun. pattern attribute. as long as the requirenent can be defined in regex pattern its your main weapon.
html5 really up the form validation so that we dont really need to create an eventlistener just for that
0
Use( required ) booleans and (type , pattern) attribute for form validation