Content
@
0 reply
0 recast
0 reaction
Robotandkid
@robotandkid
vanilla JS challenge: if you ever asked yourself why peeps use state management libraries or why front-end frameworks like React exist, try to code this simple app using only vanilla JS: User requirements =============== - User must enter an email, name. Phone number is optional. - Email must be a valid email. - Name must have at least two letters. - Phone must be a valid US number. - Disable the submit button whenever the form is invalid (and enable it whenever the form is valid). - Show an error state on the first invalid user input (and hide it whenever the form is valid)
1 reply
1 recast
7 reactions
aled
@aled
All of the above is supported out of the box with modern form validation HTML. No JavaScript required. Mark the required fields as `required`, add a `min` length to the name. Add the appropriate patterns to email and phone inputs. The form submit button will not enable unless all the validation rules pass. Use CSS to style as needed.
0 reply
0 recast
0 reaction