Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #130 from cfpb/focus
Browse files Browse the repository at this point in the history
Add focus and trim whitespace
  • Loading branch information
wpears authored Jul 27, 2017
2 parents dad574c + c38b774 commit 77a32da
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions keycloak/themes/hmda/login/register.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</#if>

<label for="firstName">${msg("firstName")}</label>
<input type="text" id="firstName" class="${properties.kcInputClass!}" name="firstName" value="${(register.formData.firstName!'')?html}" />
<input type="text" id="firstName" class="${properties.kcInputClass!}" name="firstName" value="${(register.formData.firstName!'')?html}" autofocus />

<label for="lastName">${msg("lastName")}</label>
<input type="text" id="lastName" name="lastName" value="${(register.formData.lastName!'')?html}" />
Expand Down Expand Up @@ -154,23 +154,30 @@ function addInstitutionsToInput() {
}
$(document).ready(function() {
$('#email').on('blur keyup', function(e) {
var email = $('#email');
email.on('blur keyup', function(e) {
// keycode (tab key) used to not warn when first tabbing into the email field
if(($('#email').val() === '' || $('#email').val() === null) && e.keyCode !== 9) {
if((email.val() === '' || email.val() === null) && e.keyCode !== 9) {
$('#institutions').html('<span class="hmda-error-message">${msg("hmdaEnterEmailAddress", (properties.supportEmailTo!''))}</span>');
} else {
// e.keyCode will be 'undefined' on tab key
// don't make the API call on tab keyup
if(emailExp.test($('#email').val()) && e.keyCode) {
getInstitutions(emailToDomain($('#email').val().trim()));
if(emailExp.test(email.val()) && e.keyCode) {
getInstitutions(emailToDomain(email.val().trim()));
}
}
});
if($('#email').val() !== '' && $('#email').val() !== null) {
getInstitutions(emailToDomain($('#email').val()));
if(email.val() !== '' && email.val() !== null) {
getInstitutions(emailToDomain(email.val()));
}
// remove whitespace from email to prevent 'invalid email'
email.on('blur', function(e) {
email.val($.trim(email.val()))
})
$('#institutions').on('click', '.institutionsCheck', addInstitutionsToInput);
// compare passwords
Expand Down

0 comments on commit 77a32da

Please sign in to comment.