I have the following jQuery.
$(document).ready(function() {
$('#name').bind('keypress', function(e) {
if($('#name').val().length == 0){
if (e.which == 32){//space bar
e.preventDefault();
}
}
});
});
It accepts any character except space when the length is 0. How do I allow user to enter only a-z A-z 0-9 _ and space(in between characters)?