Skip to content

Commit 07a4fd6

Browse files
authored
Update and rename Script.js to Script.js
Moved to Regex folder and added comment to explain the Regex.
1 parent f1f5267 commit 07a4fd6

File tree

1 file changed

+8
-0
lines changed
  • Specialized Areas/Regular Expressions/Username validation

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ function onSubmit() {
44

55
// Define the regex pattern for a strong username
66
var usernamePattern = /^[a-zA-Z][a-zA-Z0-9]{5,}$/;
7+
8+
// Regex explanation:
9+
// ^ : Start of string
10+
// [a-zA-Z] : First character must be a letter
11+
// [a-zA-Z0-9] : Remaining characters can be letters or digits
12+
// {5,} : At least 5 more characters (total minimum length = 6)
13+
// $ : End of string
14+
715

816
// Validate the username against the pattern
917
if (!usernamePattern.test(username)) {

0 commit comments

Comments
 (0)