Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

need to restrict fields to accept text in only one language Arabic only or English only

New Here ,
Apr 25, 2019 Apr 25, 2019

I have two pdf forms, one in English language, the other is in Arabic, how to restrict the fields of each form to accept only English text for the fields of the English form, and only Arabic text for the fields of the Arabic form? thank you

TOPICS
Acrobat SDK and JavaScript , Windows
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 26, 2019 Apr 26, 2019

You can use the following code as the custom validation script of your field to reject any values that contain English letters:

if (/[a-z]/gi.test(event.value)) {

    app.alert("Error! This field may not contain any English letters.");

    event.rc = false;

}

And this one to reject any values that contain Arabic letters:

if (/[\u0600-\u06FF]/g.test(event.value)) {

    app.alert("Error! This field may not contain any Arabic letters.");

    event.rc = false;

}

Translate
Community Expert ,
Apr 25, 2019 Apr 25, 2019

This would be interesting Mazen! I suppose once you create a text field, then any one filling the form can switch to the language of choice with no restriction. I'd also like to get the script if any one helps out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 26, 2019 Apr 26, 2019

You can use the following code as the custom validation script of your field to reject any values that contain English letters:

if (/[a-z]/gi.test(event.value)) {

    app.alert("Error! This field may not contain any English letters.");

    event.rc = false;

}

And this one to reject any values that contain Arabic letters:

if (/[\u0600-\u06FF]/g.test(event.value)) {

    app.alert("Error! This field may not contain any Arabic letters.");

    event.rc = false;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2019 Apr 27, 2019

The script works well, it will not accept English text entry for the first code, and no Arabic in the second. An error will pop up indicating that a wrong language is being used. I changed displayed message to… Arabic Only بالعربية فقط

Thanks try67

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2019 Apr 27, 2019

it worked nicely, thank you so much try67

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 27, 2019 Apr 27, 2019

The problem is, IMHO, that there are valid accented letters in English, and (assuming) valid latin letters in Arabic text. That would have to be taken care of with additional logic. An additional question is how to treat numbers, particularly if you want to have some calculations involved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2019 Apr 27, 2019

My script doesn't reject accented characters in the English field, only those characters that fall within the "block" of Arabic characters in Unicode.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2019 Apr 28, 2019

Nor does it reject numbers, in either one of the codes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 28, 2019 Apr 28, 2019

Does it reject accented latin characters in the Arabic field?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 29, 2019 Apr 29, 2019
LATEST

Yes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines