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,"")); });
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
Post a Comment