Wednesday, January 21, 2015

Email ,Phone Number , Web site validation in Java

Email ,Phone Number , Web site validation in Java


Email Validation :


String email = "pouselv@xxx.com";

Boolean validEmail = email.matches("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}");


Number Validation :


String phone= "pouselv@xxx.com";

Boolean validPhone = phone.matches("([0-9//(//)//+//-]+)");


Website Validation:

String website= "pouselv@xxx.com";

Boolean validSite = website.matches("^((http[s]?|ftp):\\/)?\\/?[A-Za-z0-9.-]{3,}.[A-Za-z]{3}");

No comments:

Post a Comment