MADPADGE
MADPADGE

Reputation: 113

android - java form validation

I was hoping someone could point me in the right direction. I'm looking for a resource that can show me how to validate user input within forms(contact forms) similar to JavaScript validation. I have searched all over the web and cant seem to find anything.

thanks everyone

Upvotes: 2

Views: 1895

Answers (3)

if u re looking sfor some simple validation , then consider your java file as simple javascript function .

step 1 : make a base class with all the validation function like

    public boolean isEmail(String fieldValue) 
        {
            Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
            Matcher m = p.matcher(fieldValue);
            if(!m.matches()) {
                return false;
            } else {
                return true;
            }
        }

step 2 : initialize a variable valid = true ;

step 3 : initialize an object for this validator class in your desired form page

step 4 : call a validation function on click of form submit button

step 5 : use the object to call the validation function on your desired page and according to the result it gives , set valid = false or leave ,

step 6 : finally 

    if(valid) 

        { ... submit the form ...}

Upvotes: 0

Imran Rana
Imran Rana

Reputation: 11889

Use regular expression, here is an excellent tutorial : Validation

Upvotes: 1

Jeje Doudou
Jeje Doudou

Reputation: 1706

You can, for example, check the input using Regex... "Regex on Google"

"Regex Android" on Google

Topic about an example of handling Regex, in android

Upvotes: 1

Related Questions