is there way check see if input filled in typing in it? right code checks see if input filled in , displays div after user clicks out of input. wanting div display once future validation methods have been met...without having click outside of input.
also there way keep div display if user have go , delete data in input?
$(function () { var _=$('input'); _.change(function() { if (_.filter(function (){return $(this).val().length }).length==_.length) $('.next').show(); else $('.next').hide(); }); });
.next { display: none; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input id="name" type="text" /> <input id="email" type="text" /> <a class="next">show div</a>
the onchange
event fired if leave (blur) input element. track updates independent of input focus state, have use event type, example onkeydown
or onkeypress
.
$(function () { var $input = $('input'); $input.on('keypress', function() { if ($input.filter(function (){return $(this).val().length }).length == $input.length) { $('.next').show(); } else { $('.next').hide(); } }); });
Comments
Post a Comment