Sudipta Som
Sudipta Som

Reputation: 6567

edit text in android

hi i want to restrict the special characters (!,@,#,$ etc.) from entering in to Edit Text field in android. how to do this please any body help.. thnx.

Upvotes: 1

Views: 753

Answers (2)

Alexander Stolz
Alexander Stolz

Reputation: 7544

You need to look at the reference. EditTest inherits from TextView: http://developer.android.com/reference/android/widget/TextView.html

There you can add an TextChangedListener:
addTextChangedListener(TextWatcher watcher)

Then you test for your special characters and remove them if they are found

Upvotes: 1

matekm
matekm

Reputation: 6030

You need to use input filter and set it on Edit Text with setFilters method

Upvotes: 6

Related Questions