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

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -