0

I'am working on the Magento store that have Arabic language store and English language store.

I have added the "letters-only" validation on firstName input field on registration page and when I check this validation on English version its working fine, but in Arabic version validation not working.

"Letters only" validation not accept Arabic string.

I'm trying below rules one by one but no luck:-

//return this.optional(element) || !/^[0-9_]+$/i.test(value);
return this.optional(element) || /^[\p{Arabic}a-zA-Z\- .ـ]+$/i.test(value);             
return this.optional(element) || /^[a-zA-Z\-+,()/'\s\p{Arabic}]+$/i.test(value);
return this.optional(element) || /^[\s\p{Arabic}]+$/i.test(value);

Please suggest any solution to get rid this issue So in Arabic version user can add their information.

Thanks!!!

0

To validate the Arabic language characters you have to use the Unicode.

var unicode=e.charCode? e.charCode : e.keyCode

You can check the Example on GIT from here.

0

After spent more time on this, I get the solution to fix this issue.

Copy the validation.js file from below path:

lib\web\mage\validation.js

put in below directory:

**app\design\frontend\venorName\themename\web\mage\validation.js**


'letters-only': [
            function (value, element) {
                return this.optional(element) || /^[a-zA-Z \u0600-\u06ff]+$/i.test(value);              
            },
            $.mage.__('Letters only please')
        ],

After above changes 'letters-only' validation working well in Arabic version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.