registration form validation in android and check conferm password in android app

 



As a learn the previous tutorial I have to try to develop a registration form with the help of XML and java in android Studio.  in a previous tutorial I have complete the registration form but we are not complete the form validation in App. now we are trying to complete it, but in this hear i have write-only MainActivity code but you can refer previous registration form design code click hear  

now Start form Validation


package com.bspl.form;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Registation extends Activity {
Button Registation;
EditText name,emailid,phonenumbe,password,confermpassword;
String str_name,str_emailid,str_phonenumbe,str_password,str_confermpassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registation);
Registation=findViewById(R.id.bt_login);
name=findViewById(R.id.Et_Name);
emailid=findViewById(R.id.Et_Emailid);
phonenumbe=findViewById(R.id.Et_phonenumber);
password=findViewById(R.id.Et_password);
confermpassword=findViewById(R.id.Et_confermpassword);

Registation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// form validation starting hear
volidation();

}
});
}

private void volidation() {
str_name=name.getText().toString();
str_emailid=emailid.getText().toString();
str_phonenumbe=phonenumbe.getText().toString();
str_password=password.getText().toString();
str_confermpassword=confermpassword.getText().toString();
if(str_name.equals("")){
name.setError("Please Enter Name");
}
else if(str_emailid.equals("")){
emailid.setError("Please Enter Email Id");
}
else if(str_phonenumbe.equals("")){
phonenumbe.setError("Please Enter Phone Number");
}
else if(str_password.equals("")){
password.setError("Please Enter Password");
}
else if(!str_confermpassword.equals(str_password)){
Toast.makeText(this, "Password is not match", Toast.LENGTH_SHORT).show(); }
else {
Toast.makeText(this, "Now Form is valid"+str_name, Toast.LENGTH_SHORT).show();
}
}
}


Comments

Popular posts from this blog

How to Integrate or Work with Open Street Map (OSM) in an Android App (Kotlin)

ListView in android with api and volley Network Library in android Studio.

how to implement OpenStreetMap in android