To restrict an input field to alphanumeric only, I use the following on my site:
<input
type=text
name=url_code
pattern=[a-zA-Z0-9_-]{4,10}
class=widefat-main
title=4 to 10 alphanumerical characters only
/>
However for browsers that don't support HTML5, what is the best way to get the same restrictions?