mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-16 02:36:01 -07:00
updated signup validation
added user validation messages to the signup page
This commit is contained in:
parent
4b817c39b1
commit
7f9815191b
2 changed files with 39 additions and 2 deletions
|
|
@ -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 (
|
return (
|
||||||
<div className="auth-wrapper">
|
<div className="auth-wrapper">
|
||||||
<div className="auth-inner">
|
<div className="auth-inner">
|
||||||
<form id="form" onSubmit={handleSubmit}>
|
<form className="needs-validation" id="form" onSubmit={handleSubmit} noValidate>
|
||||||
<h3>Sign Up</h3>
|
<h3>Sign Up</h3>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label>First name</label>
|
<label>First name</label>
|
||||||
|
|
@ -58,10 +75,14 @@ export default function SignUp() {
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder='First Name'
|
placeholder='First Name'
|
||||||
|
pattern="\S(.*\S)?"
|
||||||
value={firstName}
|
value={firstName}
|
||||||
onChange={(event) => setFirstName(event.target.value)}
|
onChange={(event) => setFirstName(event.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
<div className='invalid-feedback'>
|
||||||
|
Please enter a valid first name
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label>Last name</label>
|
<label>Last name</label>
|
||||||
|
|
@ -69,10 +90,14 @@ export default function SignUp() {
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder="Last name"
|
placeholder="Last name"
|
||||||
|
pattern="\S(.*\S)?"
|
||||||
value={lastName}
|
value={lastName}
|
||||||
onChange={(event) => setLastName(event.target.value)}
|
onChange={(event) => setLastName(event.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
<div className='invalid-feedback'>
|
||||||
|
Please enter a valid last name
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label>Email address</label>
|
<label>Email address</label>
|
||||||
|
|
@ -84,6 +109,9 @@ export default function SignUp() {
|
||||||
onChange={(event) => setEmail(event.target.value)}
|
onChange={(event) => setEmail(event.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
<div className='invalid-feedback'>
|
||||||
|
Please enter a valid email address
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
|
|
@ -91,10 +119,19 @@ export default function SignUp() {
|
||||||
type="password"
|
type="password"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder="Enter password"
|
placeholder="Enter password"
|
||||||
|
pattern="\S(.*\S)?"
|
||||||
|
minLength="8"
|
||||||
value={password}
|
value={password}
|
||||||
onChange={(event) => setPassword(event.target.value)}
|
onChange={(event) => setPassword(event.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
<div className='invalid-feedback'>
|
||||||
|
Please enter a valid password
|
||||||
|
<br/>
|
||||||
|
Your new password must be at least 8 characters long
|
||||||
|
<br/>
|
||||||
|
It cannot have whitespace at the start or end of it
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-grid">
|
<div className="d-grid">
|
||||||
<button type="submit" className="btn btn-primary mb-3">
|
<button type="submit" className="btn btn-primary mb-3">
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export default function Welcome() {
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Button className="mx-auto" variant="outline-success" href="/signup">Create an account for free</Button>
|
<Button className="mx-auto mb-5" variant="outline-success" href="/signup">Create an account for free</Button>
|
||||||
</Container>
|
</Container>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue