// Решени для javascript function setValidator(id, regex) { var element = document.getElementById(id); if (element) { var lastValue = element.value; if (!regex.test(lastValue)) lastValue = ''; setInterval(function() { var value = element.value; if (value != lastValue) { if (regex.test(value)) lastValue = value; else element.value = lastValue; } }, 10); } } // Решение для jQuery $(document).ready(function(){ $('.inputField').keyup(function(){ var login = $(this).val(); var shablon = /[А-Яа-я]{1,50}/; var resultCheck = login.match(shablon); if (resultCheck==login && resultCheck!=null){ //$('#info').text(""); } else{ var kolich= login.length; //$('#info').text("Разрешены буквы"); login = login.slice(0,kolich-1); $(this).val(login); } }); });/*end ready*/ <input type="text" id="test" class='inputField'/> <input type="text" id="test2" class='inputField'/> <input type="text" id="test3" class='inputField'/> <input type="text" id="test4" class='inputField'/> <script type="text/javascript"> setValidator('test', /^[а-яА-я-]*$/); </script>