清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1、问题背景
问题:一个输入框,输入的是月份,保证输入的内容只能是非负正整数
2、JavaScript代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function checkMonth() { $( "month" ).keyup( function (){ var temp = $( this ).val(); $( this ).val(temp.replace(/ \ D/^0/g, '' )); })bind( "paste" , function (){ var temp = $( this ).val(); $( this ).val(temp.replace(/ \ D/^0/g, '' )); }).css( "ime-mode" , "disabled" ); } |
3、页面代码
<label>月份:</label>
<input type="text" id="month"/>