mXX
mXX

Reputation: 3625

Edittext form validation

I have a form where I've put a validation like this

if( firstName.getText().toString().length() < 3 )
    firstName.setError( "First name is required!" );

So if the inputted text is smaller than 3 characters I get an error with the text "First name is required!" and I also get a red icon in the editText. But I'd like to have an elsefor when the inputted data is correct so I'll get a green icon in the editText. What property can I use for that?

EDIT: Is it also possible to do a check while typing and not after pressing a button?

Upvotes: 1

Views: 125

Answers (1)

Blackbelt
Blackbelt

Reputation: 157487

yourEditText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.youGreenDrawable, 0, 0, 0);

You have to use setCompoundDrawablesWithIntrinsicBounds

Upvotes: 1

Related Questions