Below code disables 0 as the first character in #foo. However, you can bypass this by typing 123, then drag to select 123
0
#foo
123
Here's the fixed version :
$('input#foo').keyup(function(e){ if(this.value.substring(0,1) == "0") { this.value = this.value.replace(/^0+/g, ''); } });
jsfiddle : http://jsfiddle.net/ewmb1yq9/4/