I am using the following React Function for email Regex, but it doesn't work.
When i try this email-address: test@test.com
i get the the error: "Email is invalid"
Here is my FormValidation Function to check the values:
import { emailRegex } from "./regex";
export function validateEmail(email) {
if (!email.length) {
return {
status: true,
value: "Email is required"
};
} else if (!emailRegex.test(email)) {
console.log(email);
return {
status: true,
value: "Email is invalid"
};
}
return {
status: false,
value: ""
};
}
export function validatePassword(password) {
if (!password.length) {
return {
status: true,
value: "Password is required"
};
} else if (password.length <= 6) {
return {
status: true,
value: "Password is invalid"
};
}
return {
status: false,
value: ""
};
}
and here is my emailRegex Function:
export const emailRegex = /^(([^<>()[]\\.,;:\s@\"]+(\.[^<>()[]\\.,;:\s@\"]+)*)|(\".+\"))@(([[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
Where is the issue of that? Thanks for our help