nric validation

This commit is contained in:
2025-02-09 21:18:27 +08:00
parent 462ec66a26
commit e7d92377ce

View File

@@ -40,6 +40,11 @@ export default function SignupView({
toast.error("All fields are required."); toast.error("All fields are required.");
return false; return false;
} }
const nricRegex = /^[A-Za-z][0-9]{7}[A-Za-z]$/;
if (!nricRegex.test(nric)) {
toast.error("Please enter a valid NRIC.");
return false;
}
if (password !== confirmPassword) { if (password !== confirmPassword) {
toast.error("Passwords do not match."); toast.error("Passwords do not match.");
return false; return false;
@@ -61,8 +66,8 @@ export default function SignupView({
firstName, firstName,
lastName, lastName,
gender: Number(gender), gender: Number(gender),
nationalRegistrationIdentityCardNumber: nric, nationalRegistrationIdentityCardNumber: nric.toUpperCase(),
email: emailValue, email: emailValue.toLowerCase(),
password, password,
dateOfBirth: new Date(dateOfBirth), dateOfBirth: new Date(dateOfBirth),
resumeName: "", resumeName: "",