I am using the .alphanumeric plugin for jQuery which is certainly doing what I would expect as users type directly into the textbox. But, if a user were to copy and paste a value into the text box, all bets are off.
$("#<%= txtNumber.ClientID %>").alphanumeric({allow:"-"});
I can certainly do this:
$(document).ready(function() {
$("#<%= txtNumber.ClientID %>").blur(function() {
$("#<%= txtNumber.ClientID %>").val(
RemoveInvalidCharacters(
$("#<%= txtNumber.ClientID %>").val()
)
);
});
});
//FUNCTION REMOVES ANY ; IN TEXT TO PREVENT SQL INJECTION
function RemoveInvalidCharacters(text) {
return text.replace(';', '');
}
But... I'd rather not have to kluge up my code even further with .blur() functions. Are there any other ways around this?