I have a form where I have a couple hundred text boxes and I'd like to remove any commas when they are loaded and prevent commas from being entered. Shouldn't the follow code work assuming the selector is correct?
$(document).ready(function () {
$("input[id*=_tb]")
.each(function () {
this.value.replace(",", "")
})
.onkeyup(function () {
this.value.replace(",", "")
})
});
inputevent instead ofkeyup. Your protection can be overcome by pasting commas by rightclick->contextmenu->paste, which won't triggerkeyup.