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, Macintosh, Windows

Views

606

Likes

translate

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

Most Valuable Participant , 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;}

Likes

translate

Translate

Translate
Adobe Community Professional ,
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.

Likes

translate

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
Most Valuable Participant ,
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;

}

Likes

translate

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
Adobe Community Professional ,
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

Likes

translate

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

Likes

translate

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.

Likes

translate

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
Most Valuable Participant ,
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.

Likes

translate

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
Most Valuable Participant ,
Apr 28, 2019 Apr 28, 2019

Copy link to clipboard

Copied

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

Likes

translate

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?

Likes

translate

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
Most Valuable Participant ,
Apr 29, 2019 Apr 29, 2019

Copy link to clipboard

Copied

Yes.

Likes

translate

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