Android Email Validation on EditText

前端 未结 13 1046
陌清茗
陌清茗 2020-12-29 04:38

I have one edittext and I would to to write email validation in my Editttext this is a xml code



        
13条回答
  •  伪装坚强ぢ
    2020-12-29 05:10

    Use this function for validating email id:

     private boolean validateEmaillId(String emailId){
    
        return Pattern.compile("^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
                + "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
                + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
                + "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
                + "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
                + "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$").matcher(emailId).matches();
    }
    

提交回复
热议问题