← React Intermediate Questions - Set 5 Q46

How can you handle form validation in React?

React Intermediate Questions - Set 5

Example

const errors = {};
if (!/^\S+@\S+$/.test(email)) errors.email = 'Invalid email';
<button disabled={Object.keys(errors).length > 0}>Send</button>

What to notice

← Back to the question list