I've a textbox of order id(7 digits), which in normal cases you copy paste from email to the textbox, many times you accidently copy one or two white spaces which causing annoying validation error.
I want jquery code in my Layout\MasterPage
that does't allow writing white spaces and when copy paste (with keyboard or mouse) numbers with white spaces removes the spaces and keeps the numbers only.
The above should happen only on textboxes with class white-space-is-dead
Do
$('.white-space-is-dead').change(function() {
$(this).val($(this).val().replace(/\s/g,""));
});
Updated copy of your fiddle.
Note that \s
may be more than you like. If so, use a literal white space instead
.replace(/ /g,""));
$('.white-space-is-dead').change(function() {
$(this).val($(this).val().replace(/\s/g,""));
});
This will remove all the white spaces using a regular expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With