Skip to content

Commit 2c10db7

Browse files
authored
Added email confirmation field to registration (#115)
Co-authored-by: michelle <Michelle Wan>
1 parent 5e00675 commit 2c10db7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/RegistrationForm.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface FormValues {
1010
firstName: string,
1111
lastName: string,
1212
email: string,
13+
emailConfirm: string,
1314
password: string,
1415
passwordConfirm: string,
1516
}
@@ -27,6 +28,7 @@ export const RegistrationForm: React.FC = (props) => {
2728
firstName: '',
2829
lastName: '',
2930
email: '',
31+
emailConfirm: '',
3032
password: '',
3133
passwordConfirm: '',
3234
};
@@ -42,6 +44,12 @@ export const RegistrationForm: React.FC = (props) => {
4244
if (!values.email) {
4345
errors.email = t('required');
4446
}
47+
if (!values.emailConfirm) {
48+
errors.emailConfirm = t('required');
49+
}
50+
if (values.email && values.emailConfirm && values.email !== values.emailConfirm) {
51+
errors.emailConfirm = t('email-slash-username-confirm-error');
52+
}
4553
if (!values.password) {
4654
errors.password = t('required');
4755
}
@@ -138,6 +146,15 @@ export const RegistrationForm: React.FC = (props) => {
138146
{errors.email ? errors.email : null}
139147
</div>
140148
</div>
149+
<div className={`epform__group ${errors.emailConfirm ? '--error' : ''}`}>
150+
<label htmlFor="email" className="epform__label">
151+
{t('email-slash-username-confirmation')} *
152+
</label>
153+
<input id="email" name="emailConfirm" className="epform__input" type="email" onChange={handleChange} value={values.emailConfirm} />
154+
<div className="epform__error">
155+
{errors.emailConfirm ? errors.emailConfirm : null}
156+
</div>
157+
</div>
141158
<div className={`epform__group ${errors.password ? '--error' : ''}`}>
142159
<label htmlFor="password" className="epform__label">
143160
{t('password')} *

src/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@
9191
"password": "Password",
9292
"register": "Register",
9393
"invalid-email-or-password": "Your email or password is invalid.",
94+
"email-slash-username-confirm-error": "The specified emails/usernames do not match.",
9495
"password-confirm-error": "The specified passwords do not match",
9596
"register-new-account": "Register a New Account",
9697
"first-name": "First Name",
9798
"last-name": "Last Name",
9899
"email-slash-username": "Email/Username",
100+
"email-slash-username-confirmation": "Email/Username Confirmation",
99101
"password-confirmation": "Password Confirmation",
100102
"submit": "Submit",
101103
"required": "Required",

0 commit comments

Comments
 (0)