I am creating a credit card page for my mobile website. I want that as soon as I enter the number, say, 5, the image in input box should be of maestro-card, entering 4 changes the image to be that of some other card, and so on. Much as the Clear Trip mobile site does.
I used JavaScript's onkeypress
event but it receives an action when there is no value is in the text box.
<input type="text" size="20" autocomplete="off" style="width:80%" onkeypress="func();"/> <div class="card-img"></div>
How should I do it?