diff --git a/src/components/signup/formRow.jsx b/src/components/signup/formRow.jsx
index 42387bb..5568a66 100644
--- a/src/components/signup/formRow.jsx
+++ b/src/components/signup/formRow.jsx
@@ -1,4 +1,4 @@
-export default function FormRow({ label, type = "text", value, onChange, children, required = false }) {
+export default function FormRow({ label, type = "text", value, onChange, children, required = false, ...rest }) {
return (
d.toISOString().split("T")[0];
+
const handleSignup = async () => {
setError("");
@@ -57,6 +65,19 @@ export default function SignupPagePatient() {
return;
}
+ // Validate date of birth range
+ if (dateOfBirth) {
+ const dob = new Date(dateOfBirth);
+ if (dob > dobMax) {
+ setError("Date of birth must be at least 1 day in the past.");
+ return;
+ }
+ if (dob < dobMin) {
+ setError("Date of birth cannot be more than 110 years ago.");
+ return;
+ }
+ }
+
setLoading(true);
try {
const response = await fetch(`${API_BASE_URL}/api/auth/signup`, {
@@ -155,6 +176,8 @@ export default function SignupPagePatient() {
type="date"
value={dateOfBirth}
onChange={(e) => setDateOfBirth(e.target.value)}
+ min={toDateStr(dobMin)}
+ max={toDateStr(dobMax)}
required
/>
setNicNo(e.target.value)}
+ onChange={(e) => setNicNo(e.target.value.replace(/\D/g, ""))}
+ inputMode="numeric"
required
/>
@@ -209,7 +233,8 @@ export default function SignupPagePatient() {
label="Contact No"
type="tel"
value={contactNo}
- onChange={(e) => setContactNo(e.target.value)}
+ onChange={(e) => setContactNo(e.target.value.replace(/\D/g, ""))}
+ inputMode="numeric"
required
/>
@@ -246,7 +271,8 @@ export default function SignupPagePatient() {
label="Guardian's Contact No"
type="tel"
value={guardianContactNo}
- onChange={(e) => setGuardianContactNo(e.target.value)}
+ onChange={(e) => setGuardianContactNo(e.target.value.replace(/\D/g, ""))}
+ inputMode="numeric"
required
/>