javascript - jquery input - how to handle text change correctly -
this question has answer here:
i know question has been asked multiple times, there no clear answer it. trying process (an ajax call) when user writing on input. tried use onchange
event, not seem work. can't understand why. here' code:
html:
<input type="text" required="" class="form-control" name="email" placeholder="adresse email" id="email">
js
$("#email").change(function() { alert("here"); /**** process ****/ });
and here fiddle : jsfiddle
i saw in other posts 1 should not use change event, can't find clear answer how correctly.
you said want fire when user writing on input, appropriate event use here onkeyup
, how should code:
$("#email").on('keyup', function() { console.log("typing ..."); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" required="" class="form-control" name="email" placeholder="adresse email" id="email">
note:
avoid using alert()
try alert message whenever enter character.
Comments
Post a Comment