var sliv = {}; sliv.currentLocaleCode = 'US'; sliv.foreignAlphabetLocales = ['GR', 'RU', 'PL']; sliv.preventCutPasteInInputs = function(){ $(document).on('copy paste', 'input', function (e) { e.preventDefault(); }); }; sliv.forceCharsetOnForms = function(charset){ $('form').attr('accept-charset', charset) }; function disableKeyboard(){ $(document).on('copy paste', 'input', function (e) { e.preventDefault(); }); } $(document).ready(function(){ $(document).on('keyup', 'input', function(e){ var stringa =$(this).val(); //cirillic var patt = /[а-яА-Я]+/g; //greek var patt2 = /[α-ωΑ-Ω]+/g; //polish var patt3 = /[ĄĆĘŁŃÓŚŹŻąćęłńóśźż]+/g; if(patt.test(stringa) || patt2.test(stringa) || patt3.test(stringa)){ $(this).val(""); //disableKeyboard(); } }); if(sliv.foreignAlphabetLocales.indexOf(sliv.currentLocaleCode) != -1){ sliv.preventCutPasteInInputs(); sliv.forceCharsetOnForms("UTF-8"); } });