Showing posts with label check special character in android. Show all posts
Showing posts with label check special character in android. Show all posts

Monday, 7 January 2013

Check Special Character Exist,Is Null,Is empty in android


Here Are Some Function for validation


if value has any special character in that function return value "true" otherwise "false"

       public booleanHasSpecialCharacter(String value)

       {
              for (int i = 0; i < value.length(); i++) {
                     if (!Character.isLetterOrDigit(value.charAt(i)))
                           return true;
              }
              return false;
       }


==============================================
if value has NULL function return value "true" otherwise "false"


        public boolean IsNull(Object value) {
         if (value != null)
          return true;

         return false;
        }



Note:- You can pass any object in this function (eg. TextView,EditText,....)
===================================================
if value has no data & null value in that  function return value "true" otherwise "false"

        public static boolean IsEmpty(String value)

        {
         if (IsNull(value)) {
          return true;
         } else {
          if (value.trim().length() <= 0) {
           return true;
          }
         }
         return false;
        }


Call web services easily

get source code from here, Download