I have the following code which prevents user from entering space when the length is 0. Now, how can I prevent user from entering all special characters(anything other than a-z A-Z 0-9) when the length is 0?
$('#DivisionName').bind('keypress', function(e) {
if($('#DivisionName').val().length == 0){
if (e.which == 32){//space bar
e.preventDefault();
}
}
});
This is my text box.
<input type="text" id="DivisionName" />