File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff 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 - z A - Z ] .* [ a - z A - Z ] ) [ a - z A - Z 0 - 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 - z A - 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
You can’t perform that action at this time.
0 commit comments