最近在写一个注册逻辑,需要QQ号码,所以需要判断是否为纯数字。
if (!QQNumber.getText().matches("[0-9]+")) {
//判断QQ号码是否为纯数字
JOptionPane.showMessageDialog(null, "QQ号码必须为6-10位的纯数字!", "错误", JOptionPane.ERROR_MESSAGE);
return;
}
原文:https://www.cnblogs.com/CoronaZero/p/14615386.html