javascript - Activate function once 12 characters are entered into text box -
i new mvc 4 , making internet application uses hand scanner fill text box. hoping have automatically activate javascript function once barcode has been scanned.
scanning barcode fills active textbox 12 characters, , have click button after each scan. there way automatically activate button or javascript function after barcode scanned, or after 12th character entered?
$('#mytextbox').attr('maxlength','12'); $(document).on('change','#mytextbox',function(e) { if ($(this).val().length >= 12) { $('#mybutton').click(); } }); or, if scanner routine supports keyboard events:
$('#mytextbox').attr('maxlength','12'); $(document).on('keyup','#mytextbox',function(e) { if ($(this).val().length >= 12) { $('#mybutton').click(); } }); either way, solution requires jquery, javascript library.
Comments
Post a Comment