[SOLVED]-PREVENT TO SEND FORM IF THERE IS AN ERROR-REACTJS
PREVENT TO SEND FORM IF THERE IS AN ERROR-REACTJS
you are missing a condition in submit method. you are not validating whether there is any error in validation. it should be as follows. updated the codesandbox as well
function handlesubmit(e) {
e.preventdefault();
setissubmitting(true);
seterrors(validate(values));
if (validate(values) === {}) {
emailjs.sendform("gmail", template, e.target, userid).then(
(result) => {
console.log(result);
},
(errors) => {
console.log(errors);
}
);
e.target.reset();
localstorage.clear();
}
}