Reputation: 1988
I have this code
<input name="mpan[]" value="" maxlength="2" size="2">
<input name="mpan[]" value="" maxlength="2" size="3">
<input name="mpan[]" value="" maxlength="2" size="3">
<input name="mpan[]" value="" maxlength="2" size="12">
What I have to do is I am provided with a large key for example 0380112129021
. When I do Ctrl+C on that key and select any box and press Ctrl+V, the number automatically get pasted in different box, for example: first input box gets 03
, next gets 801
, next gets 112
and rest gets pasted on last one 129021
.how do i achive this from javascript
Upvotes: 2
Views: 354
Reputation: 449385
If you're looking to catch paste events (rather than the literal Ctrl+V), the onpaste
event may be for you, and is supported by most browsers according to this answer.
The splitting of the input value you could do using substring()
.
Upvotes: 1
Reputation: 11650
okay if you have no idea you should read through some stuff.
i can recommend to read about
after that you will see the answer glowing on your screen ;-)
a little hint: if you store the pressed keys to a variable, it should be cleared after the action is triggered. and you should check what you have in you keypress cache and clear illigal input.
Upvotes: 0
Reputation: 28125
Easy. On each of the input box, add an onkeyup handler and inspect the input values.
Little clarification, you're trying to do something like serial/key input boxes, right?
Upvotes: 0