Does not fulfill part of the condition. That it was clear I will describe the principle in words. A test is displayed in the input if: enable == true (the input is not fully completed), or valid == false (there are no matches for characters). It is necessary that the test be displayed under any of these conditions (and if the imput week is completely filled and if there are no matches).
Here is the part of the code that does for this condition: } else if (enable == true && valid == false ) {
The following error in a similar condition: enable == false && valid == true here while simultaneously maintaining enable == false and valid == true should pop up an alert message. But the event is triggered when 11 digits in the field, and should trigger when 12.
here is the entire condition code:
var phone = this.value; if (!phone || phone.replace(/\D/g, '').length < 12) enable = false; if (codes[phone.substr(5, 3)]) { valid = true } else if (enable == true && valid == false ) { $('.form-control').val('Некорректный ввод'); } if (enable == false && valid == true) { obj = { dates: 'дата', time: 'время', phone: phone }; obj['date'] = retite alert(obj['date']); } }).end().end() Here is the entire code of the example: http://jsfiddle.net/0xL0fctq/35/