Filtering input text using jQuery
filtering, html-input, javascript, jquery
Solution
According to the list of Unicode characters it seems you need to check symbols in the unicode range `U+0600-U+06FF`.
So if you want to prevent the insertion of every other unicode symbol you could simply check your input value against `/^[\u0600-\u06FF]+$/g` regular expression. Also note that there're many unicode ranges you may want to allow. From the page of Arabic charset in Unicode, beside Arabic (0600—06FF, 225 characters) you have
- Arabic Supplement (0750—077F, 48 characters)
- Arabic Extended-A (08A0—08FF, 39 characters)
- Arabic Presentation Forms-A (FB50—FDFF, 608 characters)
- Arabic Presentation Forms-B (FE70—FEFF, 140 characters)
- Rumi Numeral Symbols (10E60—10E7F, 31 characters)
- Arabic Mathematical Alphabetic Symbols (1EE00—1EEFF, 143 characters)
in that case add as many ranges as you need in the expression: e.g. `/^[\u0600-\u06FF\u0750-\077F\u0...]+$/g`
So, using the snippet you mentioned you should write
$('#text_input').filter_input({regex:'[\u0600-\u06FF\u0750-\077F\u0...]'});
Hope this helps. السلام عليكم
Problem
I want to filter and lock a input text. For example, in some input, a user can only type Persian/Farsi characters but not English, or when user can type in English but not Persian. Means some input only accepts Persian/Farsi characters and others only accept English. Also i foundthis http://www.thimbleopensource.com/tutorials-snippets/jquery-plugin-filter-text-input. If know any regular experssion for persian characters can help me or how can change the keyboard mode. thanks.