Skip to content

Commit 2300b5b

Browse files
committed
Initial commit
1 parent 382660b commit 2300b5b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

script.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ document.getElementById('usernameForm').addEventListener('submit', function(even
33
var errorDiv = document.getElementById('error');
44
errorDiv.innerHTML = '';
55

6-
// Check if username is alphanumeric, between 3 and 8 characters, and contain at least 2 letters and 1 number
7-
if (!/^(?=.*[0-9])(?=.*[a-zA-Z].*[a-zA-Z])[a-zA-Z0-9]{3,8}$/i.test(username)) {
8-
errorDiv.innerHTML = 'Username must be alphanumeric, between 3 and 8 characters,<br>and contain at least 2 letters and 1 number.';
6+
// Check if username is between 4 and 34 characters, containing at least 3 letters and 1 digit
7+
var regex = /^(?=(.*[a-zA-Z]){3})(?=.*\d)[^]{4,34}$/;
8+
if (!regex.test(username)) {
9+
errorDiv.innerHTML = 'Username must be between 4 and 34 characters, containing at least 3 letters <br> and 1 digit';
910
event.preventDefault();
1011
} else {
1112
// Prevent the default form submission which would cause a page reload

0 commit comments

Comments
 (0)