|
|
|
|
@ -254,7 +254,7 @@ public class RegisterView {
|
|
|
|
|
* @return boolean 用户名是否有效.
|
|
|
|
|
*/
|
|
|
|
|
private boolean validateUsernameForCode(String username) {
|
|
|
|
|
if (!isValidUsername(username)) {
|
|
|
|
|
if (isInvalidUsername(username)) {
|
|
|
|
|
showError(statusLabel, "用户名只包含英文字母和数字)");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@ -338,7 +338,7 @@ public class RegisterView {
|
|
|
|
|
*/
|
|
|
|
|
private boolean validateRegistrationInput(String username, String email,
|
|
|
|
|
String code, String password, String confirmPassword) {
|
|
|
|
|
if (!isValidUsername(username)) {
|
|
|
|
|
if (isInvalidUsername(username)) {
|
|
|
|
|
showError(statusLabel, "用户名只包含英文字母和数字");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@ -393,9 +393,7 @@ public class RegisterView {
|
|
|
|
|
try {
|
|
|
|
|
for (int i = 60; i > 0; i--) {
|
|
|
|
|
int finalI = i;
|
|
|
|
|
javafx.application.Platform.runLater(() -> {
|
|
|
|
|
button.setText(finalI + "秒后重发");
|
|
|
|
|
});
|
|
|
|
|
javafx.application.Platform.runLater(() -> button.setText(finalI + "秒后重发"));
|
|
|
|
|
Thread.sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
javafx.application.Platform.runLater(() -> {
|
|
|
|
|
@ -436,13 +434,13 @@ public class RegisterView {
|
|
|
|
|
* @param username 用户名.
|
|
|
|
|
* @return boolean 用户名格式是否有效.
|
|
|
|
|
*/
|
|
|
|
|
public static boolean isValidUsername(String username) {
|
|
|
|
|
public static boolean isInvalidUsername(String username) {
|
|
|
|
|
if (username == null || username.trim().isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// 用户名规则:只包含英文字母和数字,不限制长度
|
|
|
|
|
String usernameRegex = "^[a-zA-Z0-9]+$";
|
|
|
|
|
return Pattern.matches(usernameRegex, username.trim());
|
|
|
|
|
return !Pattern.matches(usernameRegex, username.trim());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|