fix: fix regex phone pattern in contact-form.js
This commit is contained in:
parent
1ba4b036b3
commit
f9ceb00a0b
|
@ -88,7 +88,7 @@ form.addEventListener("submit", function(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phone — match format: 123-456-7890
|
// Phone — match format: 123-456-7890
|
||||||
const phonePattern = /^(\(?\d{3}\)?[-.\s]?\d{3}[\-.\s]?\d{4})$/;
|
const phonePattern = /^(\(?\d{3}\)?[\s-.]?\d{3}[\-.\s]?\d{4})$/;
|
||||||
if (!phonePattern.test(phone)) {
|
if (!phonePattern.test(phone)) {
|
||||||
showError("phone", "Phone number format is invalid.");
|
showError("phone", "Phone number format is invalid.");
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
|
@ -143,10 +143,10 @@ form.addEventListener("submit", function(event) {
|
||||||
});
|
});
|
||||||
|
|
||||||
form.addEventListener("reset", function (event) {
|
form.addEventListener("reset", function (event) {
|
||||||
const confirmed = confirm("Are you sure you want to clear the form?");
|
const confirmed = confirm("Are you sure you want to clear the form?");
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearErrors();
|
clearErrors();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue