Commit 1113f48c authored by Nikolay Gromov's avatar Nikolay Gromov

Merge branch 'master' of github.com:nicothin/NTH-start-project

parents 0c8aa01f cb10c667
......@@ -29,8 +29,12 @@ ready(function(){
// Для всех проверяемых текстовых полей
const fieldsText = Array.from(document.querySelectorAll('input[data-check-pattern]'));
fieldsText.forEach(function(input){
input.addEventListener('blur', function(){ checkFieldText(input); });
input.addEventListener('keyup', function(){ checkFieldText(input); });
let hasBeenAlreadyBlured = false;
input.addEventListener('blur', function(){
checkFieldText(input);
if(!hasBeenAlreadyBlured) hasBeenAlreadyBlured = true;
});
input.addEventListener('input', function(){ if(hasBeenAlreadyBlured) checkFieldText(input); });
});
// Для всех проверяемых чекбоксов
......
Включается при указании на теге `form` атрибута `data-check-form`.
Для текстовых полей: по событию `blur` содержимое поля анализируется на соответствие регулярному выражению из атрибута `data-check-pattern`.
Для текстовых полей: содержимое поля анализируется на соответствие регулярному выражению из атрибута `data-check-pattern` по событию `blur`, а также по событию `input` при последующем фокусе.
Для чекбоксов: по событию `change` проверяется соответствия состояния и `data-check-state="on"` (`off`).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment