Skip to content

Commit

Permalink
Merge pull request #49 from EhsanulHaqueSiam/EhsanulHaqueSiam-patch-1
Browse files Browse the repository at this point in the history
Update Signup.java
  • Loading branch information
EhsanulHaqueSiam authored May 27, 2023
2 parents 153815a + d5506e4 commit d015c51
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions myClasses/Signup.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,29 @@ public static boolean isValidFullname(String fullname) {
String pattern = "^(?!.*\\d)(?!.*[^a-zA-Z0-9 .'-])(?!.*[ .'-]{2,})[a-zA-Z0-9 .'-]+$";
return fullname.matches(pattern);
}

public boolean validateUsername(String username) {
// Check for spaces
if (username.contains(" ")) {
if (username.indexOf(' ') != -1) {
return false;
}


// Check for symbols using regular expression
if (!username.matches("^[a-zA-Z0-9]+$")) {
return false;
}

// Check length
int length = username.length();
return length >= 3 && length <= 20;

if (length < 3 || length > 20) {
return false;
}

// Additional validation rules can be added here

return true;
}



}

0 comments on commit d015c51

Please sign in to comment.