jQuery Only allow Alphanumerics
and uppercase in text fields
HTML
<input name="one" id="one" type="text"><br />
CSS
body { margin: 20px; }
JavaScript
jQuery(function($) {
//Only allow Alphanumerics
$('#one').keyup(function(e) {
$(this).val($(this).val().replace(/[^0-9a-zA-Z]/g, ''));
if (e.which >= 97 && e.which <= 122 ) {
var newKey = e.which - 32;
}
});
});