private void checkPhoneNum(String phone, String code) {
if (code.startsWith("+")) {
code = code.substring(1);
}
if (TextUtils.isEmpty(phone)) {
Toast.makeText(getApplicationContext(), "请输入手机号码",Toast.LENGTH_SHORT).show();
return;
}
if (code == "86") {
if (phone.length() != 11) {
Toast.makeText(getApplicationContext(), "手机号码长度不对",Toast.LENGTH_SHORT).show();
return;
}
}
String rule = "^1(3|5|7|8|4)\\d{9}";
Pattern p = Pattern.compile(rule);
Matcher m = p.matcher(phone);
if (!m.matches()) {
Toast.makeText(getApplicationContext(), "您输入的手机号码格式不正确",Toast.LENGTH_SHORT).show();
return;
}
}
Check 手机号码
最新推荐文章于 2022-12-22 22:22:01 发布