Phone number validation is an important functionality in all software application, Most of the application will use a phone number as the unique id for identifying users registered in their application. Mostly all application will send an OTP to the mobile number to which the user entered.

Function for phone number validation​

fun isValidPhone(phone: CharSequence): Boolean {
    return if (TextUtils.isEmpty(phone)) {
        false
    } else {
        android.util.Patterns.PHONE.matcher(phone).matches()
    }
}

Please feel free to comment if you have newer techniques as well as ask questions. And, yeah! If this post helps you please do share!

Happy coding!


Leave a Reply

Your email address will not be published. Required fields are marked *