1、问题背景
问题:一个输入框,输入的是月份,保证输入的内容只能是非负正整数
2、JavaScript代码
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”/>
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/10053.html