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.");
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) {
toast.error("Passwords do not match.");
return false;
@@ -61,8 +66,8 @@ export default function SignupView({
firstName,
lastName,
gender: Number(gender),
nationalRegistrationIdentityCardNumber: nric,
email: emailValue,
nationalRegistrationIdentityCardNumber: nric.toUpperCase(),
email: emailValue.toLowerCase(),
password,
dateOfBirth: new Date(dateOfBirth),
resumeName: "",