Skip to main content
mazenm61778883
Participant
April 25, 2019
Answered

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

  • April 25, 2019
  • 2 replies
  • 2632 views

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

This topic has been closed for replies.
Correct answer try67

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;

}

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 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;

}

Zaid Al Hilali
Community Expert
Community Expert
April 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

Zaid Al Hilali
Community Expert
Community Expert
April 26, 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.