From a8616dfe865c284d6621c9fd144b14146e349bea Mon Sep 17 00:00:00 2001
From: V3N1TH <152465117+VenithAbey@users.noreply.github.com>
Date: Sun, 22 Mar 2026 13:14:07 +0530
Subject: [PATCH] added input restrictions in signup
---
src/components/signup/formRow.jsx | 3 +-
src/pages/Login_Signup/signupPagePatient.jsx | 32 ++++++++++++++++++--
2 files changed, 31 insertions(+), 4 deletions(-)
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
/>