Validat email in the pattern of 'string@string.string'

This commit is contained in:
Jack 2019-01-26 18:18:59 -08:00
parent 19bbc409f9
commit ad3e1f7ea4
2 changed files with 10 additions and 2 deletions

View file

@ -9,4 +9,12 @@ function validatePassword(){
}
}
password.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
confirm_password.onkeyup = validatePassword;
function validateEmail(email)
{
if(email.validity.patternMismatch)
email.setCustomValidity('Please input correct email');
else
email.setCustomValidity('');
}

View file

@ -29,7 +29,7 @@
</div>
<div class="form-group">
<label for="email">Email:</label>
<input class="form-control" type="email" id="email" required>
<input class="form-control" type="email" id="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" oninput="validateEmail(this);" required>
</div>
<div class="form-group">
<label for="password">Password:</label>