Monday, June 27, 2011

Re: Fast way for email, phone input validation

Thanks!

Sent from my BlackBerry® wireless device


From: mohamed salah <mohamedhasanshakshak@gmail.com>
Sender: google-web-toolkit@googlegroups.com
Date: Mon, 27 Jun 2011 13:42:39 +0200
To: <google-web-toolkit@googlegroups.com>
ReplyTo: google-web-toolkit@googlegroups.com
Subject: Re: Fast way for email, phone input validation


salam
there mohammad salah
validate your phone create method validate your email
 
---------------------------------------------------------------
  // this method is email for example    MM@mm.com

public static boolean isEmail(final String value) {
        boolean valid = true;
        if (value != null) {
            valid = value.matches(".+@.+\\.[a-z]+");

            if (value.contains(" ")) {
                valid = false;
            }
        }

        return valid;

    }
---------------------------------------------------------------

// this method is email is not empty
public static boolean isEmptyValue(final String value) {
        boolean valid = true;
        if (value == null) {
            return valid = false;
        }
        if (value.trim().equals("")) {
            return valid = false;
        }

        return valid;
    }
---------------------------------------------------------------
// this method is email min lenght
public static boolean checkMinlength(final String value, final int minLength) {
        boolean valid = true;
        if (value != null) {
            if (value.length() < minLength) {
                valid = false;
            }

        }

        return valid;

    }

---------------------------------------------------------------
// this method is MaX length

public static boolean checkMaXlength(final String value, final int maxLength) {
        boolean valid = true;
        if (value != null) {
            if (value.length() > maxLength) {
                valid = false;
            }

        }

        return valid;

    }
---------------------------------------------------------------

validate is Fone
---------------------------------------------------------------
create varible
public static final String RGEX_PHONE_ONLY = "^\\(?(\\d{3}-)\\)?(\\d{3}-)?(\\d{4})$";
this varible validate to phone for example method

---------------------------------------------------------------
//this method is Phone for example 111-111-1111 is true.
1111-111-1111 is not true
1111-1111-1111 is not true
111-111-111 is not true
and contune.
this method .
---------------------------------------------------------------
public static boolean isPhone(String value) {
        boolean valid = false;
        valid = value.matches(RGEX_PHONE_ONLY);
        if (valid) {
            valid = true;
        }
        return valid;
    }
---------------------------------------------------------------
Regard: Senior : Mohamed salah hasan
Mobile :+20106594094
tel     :+2024460320
Mail:mohamedhasanshakshak@gmail.com

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment