Amir_P Amir_P - 6 months ago 28
Java Question

How to detect if edittext has English characters

I want to detect if my

edittext
has English characters and notify user to change it because i want just Persian characters for name and family name. how can i filter
edittext
to accept just Persian characters or detect English characters and show an error?

Answer

I think its not easy to detect and inform user to instruct. Simply u can do something like this. In XML file:

<EditText
    android:id="@+id/LanguageText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="text"
    android:digits="@string/app_lan" />

In Strings.xml :

<string name="app_lan">YOUR LANGUAGE</string>

Example If English :

<string name="app_lan">abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>

For ur language same like this.

Comments