Back to project page android-edittext-validator.
The source code is released under:
MIT License
If you think the Android project android-edittext-validator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.andreabaccega.formedittextvalidator; //from w ww. j a va 2 s . co m import java.util.regex.Pattern; import android.os.Build; import android.util.Patterns; /** * It validates phone numbers. * Regexp was taken from the android source code. * @author Andrea Baccega <me@andreabaccega.com> * */ public class PhoneValidator extends PatternValidator{ public PhoneValidator(String _customErrorMessage) { super(_customErrorMessage, Build.VERSION.SDK_INT>=8?Patterns.PHONE:Pattern.compile( // sdd = space, dot, or dash "(\\+[0-9]+[\\- \\.]*)?" // +<digits><sdd>* + "(\\([0-9]+\\)[\\- \\.]*)?" // (<digits>)<sdd>* + "([0-9][0-9\\- \\.][0-9\\- \\.]+[0-9])")); } }