ok here is the solution that worked for me.
Note that in my application I know for sure the input language will be one of two Languages either input is English Or Arabic
so here what I did
var msgText = entered message text;
var textLength = msgText.length; // entered message length
var isEnglish = true;
for (var index = 0; index <= textLength; index = index + 1) {
if (msgText.charCodeAt(index) > 160) {
//Not English
isEnglish=false;
break;
}
}
in the previous Example that is what I Needed , if a single character is Arabic the whole text should be validated as Arabic so I added a variable isEnglish = true by default and will only be changed if a character in the string is not English
I iterated the characters in the string using the charCodeAt(index) which returns the ISO Latin-1 Character Number .
using the table in the this page I was able to decide that the maximum number in this set that represents English chars was 160 and