You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wang2/src/com/mathlearning/util/UsernameValidator.java

15 lines
460 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.mathlearning.util;
public class UsernameValidator {
public static boolean isValid(String username) {
if (username == null || username.length() < 3 || username.length() > 20) {
return false;
}
return username.matches("^[a-zA-Z0-9_]+$");
}
public static String getRequirements() {
return "用户名要求: 3-20位只能包含字母、数字和下划线";
}
}