Registration form in Android (Check if email is valid and if EditText is empty)

Registration form in Android (Check if email is valid and if EditText is empty)



On Click method:


 bt_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isConnected = ConnectivityReceiver.isConnected();
                if (isConnected) {
                    chekdata();
                } else {
                    Toast.makeText(RegisterActivity.this, "Sorry! Not connected to internet", Toast.LENGTH_LONG).show();
                }
            }
        });

check data method:



void chekdata() {
    if (ismEmpty(ed_name)) {
        ed_name.setError("Name is empty");
    }
    if (ismEmail(ed_emailid)==false) {
        ed_emailid.setError("EMail Id is not Valid");
    }
    if (ismEmpty(ed_password)) {
        ed_password.setError("Password is empty");
    }

    if (ismEmpty(ed_confirmpassword)) {
        ed_confirmpassword.setError("ConfirmPassword is empty");
    }
    if(isComapre(ed_password,ed_confirmpassword))
    {
        Toast.makeText(RegisterActivity.this,"Password and Confrim Password Not Match",Toast.LENGTH_LONG).show();
    }


}

boolean ismEmpty(EditText text) {
    CharSequence str = text.getText().toString();
    return TextUtils.isEmpty(str);
}
boolean isComapre(EditText text,EditText text1) {
    CharSequence str = text.getText().toString();
    CharSequence str1 = text1.getText().toString();

    return (!str.equals(str1));
}

boolean ismEmail(EditText text) {
    CharSequence str = text.getText().toString();
    return (!TextUtils.isEmpty(str)&& Patterns.EMAIL_ADDRESS.matcher(str).matches());
}
Registration form in Android (Check if email is valid and if EditText is empty) Registration form in Android (Check if email is valid and if EditText is empty) Reviewed by Anonymous on April 14, 2018 Rating: 5

No comments:

Java Ternary Operator

Java Ternary Operator Java ternary operator is the only conditional operator that takes three operands. Java ternary operator is a one l...

Powered by Blogger.