So, there is a form with fields. In this form, 2 fields are required, one field should contain a number from 1 to 99, and the second one from 400 to 15,000. If the appropriate data is shown in the fields, click the button below:
<img src="continue.png" alt="next" style="display: none;" id="next_kar" />
if something is wrong, we hide it. It seems simple.
Having done the processing of 1 field in this way on jquery, I was delighted - everything works as it should:
$('#karniz_asp').keyup(function(){ var karniz_asp_cnt = $('#karniz_asp_cnt').val(); if(karniz_asp_cnt > 0 && karniz_asp_cnt < 100) { $('.karniz_asp_cnt_error').css('display','none'); $('#next_karniz_asp').css('display','block'); // ΠΠΎΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΡ } else { $('.karniz_asp_cnt_error').css('display','block'); $('#next_karniz_asp').css('display','none'); // ΠΡΡΡΠ΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΡ } });
and for the second field I wrote it in the same way:
$('#karniz_asp_dlina').keyup(function(){ var karniz_asp_dlina_cnt = $('#karniz_asp_dlina').val(); if(karniz_asp_dlina_cnt > 399 && karniz_asp_dlina_cnt < 15001) { $('.karniz_asp_error').css('display','none'); $('#next_karniz_asp').css('display','block'); // ΠΠΎΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΡ } else { $('.karniz_asp_error').css('display','block').html("ΠΠ»ΠΈΠ½Π° Π΄ΠΎΠ»ΠΆΠ½Π° Π±ΡΡΡ ΠΎΡ 400 Π΄ΠΎ 15000ΠΌΠΌ."); $('#next_karniz_asp').css('display','none'); // ΠΡΡΡΠ΅ΠΌ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΡ } });
And it turned out that for the second field, showing / hiding the button for some reason already does not work! I tried to remove lines for the first field:
$('#next_karniz_asp').css('display','block'); $('#next_karniz_asp').css('display','none');
and for the second field it all miraculously worked.
The question is, why did the conflict arise? How in my case is the right thing to do? Why if you register
$ ('# next_karniz_asp'). css ('display', 'block'); $ ('# next_karniz_asp'). css ('display', 'none');
only in one block $ ('# karniz_asp_dlina'). keyup (function () {}) ;, everything works. And if you add this code to the second block $ ('# karniz_asp_dlina'). Keyup (function () {}); in the second block is no longer working? Please help.
#karniz_asp_dlina
not a child of#karniz_asp
? - zb '