I am trying to validate a users email, by checking it against an expression. But the result i am getting is invalid for all the entries.
UPDATED CODE
Having a function that validates the email (probably in some separate module as you are going to reuse it),
export function validateIsEmail(email) {
return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email);
}
You can validate email input,
Live validation:
{
setEmail(emailText);
setInlineValidations({
...inlineValidations,
emailNotValid: !validateIsEmail(emailText),
});
}}
/>
In this example setEmail and setInlineValidations are state setters defined by the useState hook, example const [email, setEmail] = useState('');
, you can of course adapt this to your way of handling state.