Mani
Mani

Reputation: 21

How to determine if user input is written in English or Arabic?

I want to validate the text of customer input using jQuery. If the customer enter Arabic text I would like to show message in Arabic. How can I do that?

Upvotes: 1

Views: 2178

Answers (1)

Moshtaf
Moshtaf

Reputation: 4903

Try this:

isArabic('Some Text');

function isArabic(strInput)
{
    var arregex = /[\u0600-\u06FF]/;
    if (arregex.test(strInput)){
        alert('Yes, Has Arabic Characters');
    }else{
        alert('No, Has Not Arabic Characters');
    }
}

Check JSFiddle Demo

Upvotes: 10

Related Questions