practicebasic
Form with validation
A simple form with name and email fields. Validate that name is not empty and email contains '@'. Show error messages below each field.
Objectives
- 1.Two fields: name and email
- 2.Errors state: { name: '
, email:' } - 3.On submit: validate name (not empty) and email (contains @)
- 4.If there are errors, show them below each field in red
- 5.If no errors, show
Success!in green
your code
Hint
Use the form's onSubmit event, preventDefault(), and validate before doing anything
Related concepts
Was this helpful?
Sign in to give feedback
