版权声明:本文出自艾派儿的博客,转载必须注明出处。 https://blog.csdn.net/ljl940811/article/details/86360728
//验证手机号
private boolean judPhone() {
if (TextUtils.isEmpty(edit_phone.getText().toString().trim())) {
Toast.makeText(AddAccountActivity.this, "请输入您的电话号码", Toast.LENGTH_LONG).show();
edit_phone.requestFocus();
return false;
} else if (edit_phone.getText().toString().trim().length() != 11) {
Toast.makeText(AddAccountActivity.this, "您的电话号码位数不正确", Toast.LENGTH_LONG).show();
edit_phone.requestFocus();
return false;
} else {
String phone_number = edit_phone.getText().toString().trim();
String num = "[1][358]\\d{9}";
if (phone_number.matches(num))
return true;
else {
Toast.makeText(AddAccountActivity.this, "请输入正确的手机号码", Toast.LENGTH_LONG).show();
return false;
}
}
}