DEV Community

Discussion on: Contact Form with Emailjs - React

Collapse
 
am20dipi profile image
Adriana DiPietro

Hi Njoku! Great article. I was wondering if you knew how to make sure that the email is NOT sent if the fields are empty. I have tried creating my own validations but the email will still send with empty input fields. Thanks in advance!

Collapse
 
ebereplenty profile image
NJOKU SAMSON EBERE

You can disable or even hide the submit button if any field is empty.

You may also do a check while trying to submit and throw an error that terminates the submission if any field is empty.

Collapse
 
emmu profile image
UH

Why you're not using 'required' in input element? If you use 'required' in each input element, you can't click 'send' button.