I'm trying to remove commas from all of my textboxes on keyup. I came up with the script below but it's not working. Can anyone see what I am doing wrong?
<script>
$("input[type='text']").keyup
(
function ()
{
alert('1');
$(this).val($(this).val().replace(/[,]/g, ""));
}
);
</script>
NOTE: please excuse the $ in Script. SO won't let me post it otherwise...
You might want to wrap that whole chunk of code in a document ready function
$(function() {
$("input:text").keyup(function() {
$(this).val($(this).val().replace(/[,]/g, ""));
});
});
You can read all about this on the jQuery documentation site.
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