Added requirement that usernames be exclusively alphanumeric

This commit is contained in:
Taylor Courage 2025-03-03 22:15:48 -05:00
parent db06888ecb
commit 6329d96331
2 changed files with 9 additions and 8 deletions

View File

@ -52,11 +52,11 @@ try { // Try opening the SQL database connection
<p>Get started on your trophy-winning journey with your very own TrojanDestinyRL account!</p> <p>Get started on your trophy-winning journey with your very own TrojanDestinyRL account!</p>
<hr> <hr>
<p></p> <p></p>
<form id="userForm" action="admin/user_management/add_user.php" onsubmit="return verifyInput()" method="POST" target="dataFrame"> <form id="userForm" action="admin/user_management/add_user.php" onsubmit="return verifyInput()" method="POST" target="dataFrame" >
<!-- THIS DIV IS FOR INPUT --> <!-- THIS DIV IS FOR INPUT -->
<div id="textInputArea"> <div id="textInputArea">
<label for="username" class="inputLabel">Username:</label> <label for="username" class="inputLabel">Username:</label>
<input type="text" id="username" name="username" class="newLine" maxlength="30" onchange="usernameConfirm()" tabindex="1"> <input type="text" id="username" name="username" class="newLine" maxlength="30" onchange="usernameConfirm()" tabindex="1" pattern="[a-zA-Z0-9]*" required>
<p id="confirmUsername"></p> <p id="confirmUsername"></p>
<label for="password" class="inputLabel">Password:</label> <label for="password" class="inputLabel">Password:</label>
<input type="password" id="password" name="password" required tabindex="1"> <input type="password" id="password" name="password" required tabindex="1">
@ -68,7 +68,7 @@ try { // Try opening the SQL database connection
<p id="matchingPasswordsText"></p> <p id="matchingPasswordsText"></p>
</div> </div>
<p>&nbsp;</p> <p>&nbsp;</p>
<input type="submit" value="CREATE" tabindex="1"> <input type="submit" value="CREATE" tabindex="1">
</form> </form>
<p>&nbsp;</p> <p>&nbsp;</p>
</div> </div>

View File

@ -21,11 +21,16 @@ function verifyInput() {
// Check if the username is filled out // Check if the username is filled out
var username = document.forms["userForm"]["username"].value; var username = document.forms["userForm"]["username"].value;
// Alert if not
if (username == "") { if (username == "") {
alert ("Must enter a username!"); alert ("Must enter a username!");
return false; return false;
} }
// Check if the name is already taken
if (!usernameConfirm()) {
alert ("Username already taken!");
return false;
}
// Check if a password is required, if so, make sure one is entered // Check if a password is required, if so, make sure one is entered
var password = document.forms["userForm"]["password"].value; var password = document.forms["userForm"]["password"].value;
@ -46,10 +51,6 @@ function verifyInput() {
return false; return false;
} }
if (!usernameConfirm()) {
alert ("Username already taken!");
return false;
}
} }
function displayPassword() { function displayPassword() {