This jQuery plugin makes an input field only contain alphanumeric characters
jQuery.fn.dnkl_onlyAlphaNumeric = function() {
/*
NAME: dnkl_onlyAlphaNumeric()
VERS: 1.0
DESC: Removes non-alpha/numeric characters from value
USAGE: $('#myInputID').dnkl_onlyAlphaNumeric();
*/
return $(this).each(function() {
$(this).keyup(function() {
var reg = new RegExp('[^0-9A-z]');
if ($(this).val().match(reg)) {
$(this).val($(this).val().replace(/[^\-0-9A-z]/g, ''));
}
});
});
}