• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
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

Copy link to clipboard

Copied

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

Views

1.8K

Translate

Translate

Report

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;

}

Votes

Translate

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

it worked nicely, thank you so much try67

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Does it reject accented latin characters in the Arabic field?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Yes.

Votes

Translate

Translate

Report

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