JavaScript Coding Challenge — Form Validation

Consider this quite common signup form, don’t worry about styling here.

<form>
<input name="name"> // required
<input name="surname">
<input name="phone"> // required and valid number
<input name="email"> // required and valid email
<input name="address">
<button type="submit">Submit</button>
</form>

Write a validation event handler that is run on form submit. Validation rules should be derived from inputs’ attributes. With that being said, feel free to add additional attributes as needed.

You may use jQuery or pure JavaScript to implement your solution.

Like what you read? Give Olek Tsukur a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.