Friday , September 17 2021

Android Form Validation Tutorial using AwesomeValidation Library – Android Coding by DMTechnolab

The package The trap.Simplified coding.androidvalidationexample;

Import Android.Support.v7.App.AppCompatActivity;

Import Android..Bundle;

Import Android.Useful.The pattern;

Import Android.Opinion.Opinion;

Import Android.Widget.switch;

Import Android.Widget.Change in writing;

Import Android.Widget.Toast;

Import With.Basigakeball.Amazing.Amazingness;

Import With.Basigakeball.Amazing.Validation;

Import With.Google.Normal.to pile up.Limit;

public class Main activity Is spread AppCompatActivity come into force Opinion.OnClickListener {{

// visual objects

Private Change in writing editTextName, editTextEmail, editTextMobile,

editTextDob, editTextAge;

Private switch buttonSubmit;

// Defining Awesome Object

Private Amazingness Awesome invalid;

@Override

Protected Zero Go ahead()Bundle saveInstanceState) {{

Super.Go ahead()saveInstanceState);

setContentView()R.Layout.activity_main);

// beginners terrible thing

/ *

* Library provides 3 types of verification

* Basic

* colour

* UNDERLABEL

* * /

Awesome invalid = New Amazingness()Validation.Basic);

// view initial items

editTextName = ()Change in writing) findViewById()R.Id.editTextName);

editTextEmail = ()Change in writing) findViewById()R.Id.editTextEmail);

editTextMobile = ()Change in writing) findViewById()R.Id.editTextMobile);

editTextDob = ()Change in writing) findViewById()R.Id.editTextDob);

editTextAge = ()Change in writing) findViewById()R.Id.editTextAge);

buttonSubmit = ()switch) findViewById()R.Id.buttonSubmit);

// add validation for edittexts

Awesome invalid.Addition()this, R.Id.editTextName, “” ^[A-Za-z\s]{1,}[\.]{0,1}[A-Za-z\s]{,}, $ “, R.Wire.Name holder);

Awesome invalid.The joint()this, R.Id.editTextEmail, The pattern.Email address, R.Wire.Name holder);

Awesome invalid.Addition()this, R.Id.editTextMobile, “” ^[2-9]{2}[0-9]{8} $ “, R.Wire.Name holder);

Awesome invalid.The joint()this, R.Id.editTextDob, “^ ^? 🙁 ?: 31 (\ / – | – | \.) (?: 0?”[13578]| 1[02])) \ 1 | (? :(?: 29 | 30) (\ / | – | – \). (?: 0)[1,3-9]| 1[0-2]) \ 2)) (? :(?: 1[6-9]|[2-9]\ d)? \ d {2}) $ | ^ (?: 29 ((\ / | – | – _). 0)? 2 \ 3 (? :(? :(?:?:[6-9]|[2-9]\ d)? (?: 0[48]|[2468][048]|[13579][26]) | (? :(?: 16 |[2468][048]|[3579][26])) 00))) $ | ^ (?: 0?[1-9]| 1 \ d | 2 |[0-8]) (\ / | – | \.) (? :(?: 0?[1-9]) | (?: 1[0-2])) \ 4 (? :(?: 1)[6-9]|[2-9]\ d)? \ d {2}) $ “, R.Wire.Name holder);

Awesome invalid.Addition()this, R.Id.editTextAge, Limit.closed()13, 40), R.Wire.older person);

buttonSubmit.setOnClickListener()this);

}

Private Zero submit Form()) {{

// First validate the form then proceed

// if it returns true ie verification is successful

If ()Awesome invalid.To validate())) {{

Toast.Makeup()this, “Verification successor”, Toast.LENGTH_LONG).Display());

// process the data further

}

}

@Override

public Zero on click()Opinion Opinion) {{

If ()Opinion == buttonSubmit) {{

submit Form());

}

}

}


Source link

About dmtechnolab

Check Also

Simplified Coding

Android ViewModel Unit Test Tutorial – Android Coding by DMTechnolab

Hi guys welcome Android ViewModel Unit Test Tutorial. This post is also part of our …

Leave a Reply

Your email address will not be published. Required fields are marked *