Skip to content

Commit

Permalink
add check for email has length before validating confirmEmail
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewHEguardian committed Jan 31, 2025
1 parent 83fa2a6 commit e14e34c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export function PersonalDetailsFields({
}}
onBlur={(event) => {
event.target.checkValidity();
confirmEmailRef.current?.querySelector('input')?.checkValidity();
if (email.length > 0) {
confirmEmailRef.current?.querySelector('input')?.checkValidity();
}
}}
readOnly={isEmailAddressReadOnly}
name="email"
Expand Down Expand Up @@ -105,8 +107,10 @@ export function PersonalDetailsFields({
} else {
if (validityState.valueMissing) {
setConfirmedEmailError('Please confirm your email address.');
} else {
} else if (validityState.patternMismatch) {
setConfirmedEmailError('The email addresses do not match.');
} else {
setConfirmedEmailError('Please enter a valid email address.');
}
}
}}
Expand Down

0 comments on commit e14e34c

Please sign in to comment.