Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if edittext has English characters

Tags:

java

android

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?

like image 537
Amir_P Avatar asked May 13 '16 11:05

Amir_P


2 Answers

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.

like image 57
User Learning Avatar answered Sep 28 '22 08:09

User Learning


Persian characters are within the range: [\u0600-\u06FF]. Validate your string with regex.

like image 26
Sergei Podlipaev Avatar answered Sep 28 '22 07:09

Sergei Podlipaev