portico: Auto-detect field to focus for registration page.

This replaces the manually-curated logic for which field to focus.
This commit is contained in:
Abhinav Singh 2018-12-04 23:18:53 +05:30 committed by Tim Abbott
parent a8113ae296
commit 586ce70b8b
1 changed files with 7 additions and 8 deletions

View File

@ -45,14 +45,13 @@ $(function () {
}
if ($("#registration").length > 0) {
if ($("#id_team_name").length === 1) {
common.autofocus('#id_team_name');
} else if ($('#id_email').length === 1 && !$('#id_email').attr('disabled')) {
common.autofocus('#id_email');
} else if ($("#source_realm_select").length === 1) {
common.autofocus('#source_realm_select');
} else {
common.autofocus('#id_full_name');
// Check if there is no input field with errors.
if ($('.help-inline:not(:empty)').length === 0) {
// Find the first input field present in the form that is
// not hidden and disabled and store it in a variable.
var firstInputElement = $("input:not(:hidden, :disabled):first");
// Focus on the first input field in the form.
common.autofocus(firstInputElement);
}
// reset error message displays