Use built-in login validation (#6434)

* Use built-in login validation

* use button instead of submit to avoid duplicate submits

---------

Co-authored-by: Simon Smith <simonsmith5521@gmail.com>
This commit is contained in:
trmdi
2024-10-19 22:47:33 +07:00
committed by GitHub
parent ac27034542
commit 63930c4b33
3 changed files with 12 additions and 48 deletions

View File

@@ -63,15 +63,15 @@
<table>
<tr>
<td id=loginusername align=right width=100>Username:</td>
<td><input id=username type=text autocomplete="username" maxlength=64 name=username onchange=validateLogin(1) onkeyup=validateLogin(1,event) /></td>
<td><input id=username type=text autocomplete="username" maxlength=64 name=username required /></td>
</tr>
<tr>
<td align=right>Password:</td>
<td><input id=password type=password autocomplete="current-password" maxlength=256 name=password autocomplete=off onchange=validateLogin(2) onkeyup=validateLogin(2,event) /></td>
<td><input id=password type=password autocomplete="current-password" maxlength=256 name=password autocomplete=off required /></td>
</tr>
<tr>
<td><div id=showPassHintLink style=display:none><a onclick=showPassHint() style="cursor:pointer">Show Hint</a></div></td>
<td align=right><input id=loginButton type=submit value="Log In" disabled="disabled" /></td>
<td align=right><input id=loginButton type=submit value="Log In" /></td>
</tr>
</table>
<div id="hrAccountDiv" style="display:none"><hr /></div>
@@ -422,7 +422,6 @@
window.onresize = center;
center();
validateLogin();
validateCreate();
if (loginMode.length != 0) { go(parseInt(loginMode)); } else { go(1); }
QV('newAccountDiv', (newAccount === '1') || (newAccount === 'true')); // If new accounts are not allowed, don't display the new account link.
@@ -573,16 +572,6 @@
}
}
function validateLogin(box, e) {
setTimeout(function(){
var ok = ((Q('username').value.length > 0) && (Q('username').value.indexOf(' ') == -1) && (Q('password').value.length > 0));
QE('loginButton', ok);
setDialogMode(0);
if ((e != null) && (e.keyCode == 13)) { if (box == 1) { Q('password').focus(); } else if (box == 2) { Q('loginButton').click(); } }
if (e != null) { haltEvent(e); }
}, 100);
}
function validateCreate(box,e) {
setDialogMode(0);
var ok = false;
@@ -818,4 +807,4 @@
</script>
</body>
</html>
</html>