javascript - Maxlength and copy paste in Cordova/PhoneGap Android Apps -


i using maxlength in cordova based android app. have implemented maxlength using code-

 $('.limit-eight').keyup(function(e) {         if (e.keycode != 8 || e.keycode != 46) {             if ($(this).val().length >= 8) {                 $(this).val($(this).val().substr(0, 8));             }         }     }); 

but whenever user copies , pastes, text pastes without restriction.

attach on paste event

  $('.limit-eight').on('paste', function() {       // logic here         console.log('text pasted!')   })​ 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -