Validate a URL / Website name in EditText in Android?

Validate a URL / Website

To validate URL/ Website name entered in a EditText, this following works fine…

private boolean isValidUrl(String url) {
      Pattern p = Patterns.WEB_URL;
      Matcher m = p.matcher(url.toLowerCase());
         return true;
        return false;

URL should be in lowercase to validate correctly. Here is ref link.

Hope this helps somebody…


Leave a Reply

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