javascript - detect string-length on paste on maxlength-set input -
this long shot, thought might ask. have text input maxlength
of 100, there anyway of detecting, on paste, if user attempted paste text string length greater 100(before shortened automatically)? thanks.
$('#limitedtext').paste(function(){ if($(this).val().length > 100) { //do somthing } }); <input type = "text" id = "limitedtext" maxlength = "100">
you remove maxlength
attribute , instead add onchange
listener current value , truncate 100.