c# - How to remove all spaces when pasting using jQuery or JavaScript instantly? -


when user pastes text field want able remove spaces instantly.

<input type="text" class="white-space-is-dead" value="dor  on" />  $('.white-space-is-dead').change(function() {        $(this).val($(this).val().replace(/\s/g,"")); }); 

http://jsfiddle.net/u3crg/22/

this code example works. doesn't update until user clicks on besides textbox. using mvc jquery/javascript.

switch event change input, trigger whenever inputted field, if text being pasted.

$('.white-space-is-dead').on('input', function() {        $(this).val($(this).val().replace(/\s/g,"")); }); 

take @ jquery events understand better options have.

edit: updated answer based on op's comment , found on this answer.


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -