V
V
Valeriy19972015-08-27 23:24:07
JavaScript
Valeriy1997, 2015-08-27 23:24:07

Where is the syntax error in the code?

Does not fulfill part of the condition. To make it clear, I will describe the principle verbally. A test is displayed in the input if: enable == true (the input is not completely filled), or valid == false (there are no matches for characters).

Here is the part of the code that is responsible for this condition , so when we initially entered the conditions into the input, all checks work out well. But when we start deleting or changing characters in the input, all checks stop working correctly. What could be the reason for this code behavior? here is the whole condition code: : } else if (enable == true && valid == false ) {


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()


and here is the whole code : jsfiddle.net/0xL0fctq/37

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2015-08-28
@Valeriy1997

If I understood you correctly, you need this result: jsfiddle.net/Murmurianez/62uzw6sa

K
Ken Jee, 2015-08-27
@Machez

Use debugging in Chrome DevTools habrahabr.ru/company/2gis/blog/246557

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question