feat: enhance contact form security and add animated hero
This commit is contained in:
parent
ea18dcdb8e
commit
8497cd819d
19 changed files with 320 additions and 112 deletions
|
|
@ -18,16 +18,13 @@ export function normalizeAndValidatePhoneNumber(rawPhoneNumber) {
|
|||
throw new Error("Phone number is required.");
|
||||
}
|
||||
|
||||
// 1. Strip all non-digit characters.
|
||||
const digitsOnly = rawPhoneNumber.replace(/\D/g, "");
|
||||
|
||||
// 2. If the number starts with a '1', remove it.
|
||||
let numberToValidate = digitsOnly;
|
||||
if (numberToValidate.startsWith("1")) {
|
||||
numberToValidate = numberToValidate.substring(1);
|
||||
}
|
||||
|
||||
// 3. Check if the resulting number is exactly 10 digits long.
|
||||
if (numberToValidate.length !== 10) {
|
||||
throw new Error("Please provide a valid 10-digit phone number.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue