diff --git a/src/pages/Signup.jsx b/src/pages/Signup.jsx index 6260c1d..2832bd8 100644 --- a/src/pages/Signup.jsx +++ b/src/pages/Signup.jsx @@ -47,10 +47,27 @@ export default function SignUp() { }); } + (() => { + // Fetch all the forms we want to apply custom Bootstrap validation styles to + const forms = document.querySelectorAll('.needs-validation') + + // Loop over them and prevent submission + Array.from(forms).forEach(form => { + form.addEventListener('submit', event => { + if (!form.checkValidity()) { + event.preventDefault(); + event.stopPropagation(); + } + + form.classList.add('was-validated') + }, false) + }) + })() + return (
-
+

Sign Up

@@ -58,10 +75,14 @@ export default function SignUp() { type="text" className="form-control" placeholder='First Name' + pattern="\S(.*\S)?" value={firstName} onChange={(event) => setFirstName(event.target.value)} required /> +
+ Please enter a valid first name +
@@ -69,10 +90,14 @@ export default function SignUp() { type="text" className="form-control" placeholder="Last name" + pattern="\S(.*\S)?" value={lastName} onChange={(event) => setLastName(event.target.value)} required /> +
+ Please enter a valid last name +
@@ -84,6 +109,9 @@ export default function SignUp() { onChange={(event) => setEmail(event.target.value)} required /> +
+ Please enter a valid email address +
@@ -91,10 +119,19 @@ export default function SignUp() { type="password" className="form-control" placeholder="Enter password" + pattern="\S(.*\S)?" + minLength="8" value={password} onChange={(event) => setPassword(event.target.value)} required /> +
+ Please enter a valid password +
+ Your new password must be at least 8 characters long +
+ It cannot have whitespace at the start or end of it +
- +
);