Android:在文本字段中检查CC电子邮件验证

时间:2016-02-03 05:10:38

标签: java android

如何在文本字段中查看cc电子邮件验证 对于空间而言应该是分开的。 ; "

private Boolean check_email_cc_validation(){

    Boolean status = true;

    if (edt_customer_cc.getText().length() != 0) {

        String str_to_split = edt_customer_cc.getText() + "";


        String split_array[] = str_to_split.split("\\;");


        for (String c : split_array) {

            c = c.trim();
            if (!c.isEmpty()) {
                if ((!isEmailValid(c))) {

                    edt_customer_cc.requestFocus();
                    edt_customer_cc.setError("Please enter valid email.");
                    status = false;
                }
            }
        }


    }
    return status;
}

1 个答案:

答案 0 :(得分:0)

private Boolean check_email_cc_validation() {

    Boolean status = true;

    if (edt_customer_cc.getText().length() != 0) {

        String str_to_split = edt_customer_cc.getText() + "";


        String split_array[] = str_to_split.split("\\;");


        for (String c : split_array) {

            c = c.trim();
            if (!c.isEmpty()) {
                if ((!isEmailValid(c))) {

                    edt_customer_cc.requestFocus();
                    edt_customer_cc.setError("Please enter valid email.");
                    status = false;
                }
            }
        }


    }
    return status;
}

boolean isEmailValid(CharSequence email){

    return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
}

会正常工作.. 只是isEmailValid(CharSequence电子邮件)丢失了