js 正则表达式判断正整数

 

<input type="number"  id="places" name="places" max="10000">

 

//js只能输入正整数(不包括负整数和0)
var places = $("#places").val();
if(!(/(^[1-9]\d*$)/.test(places))){
    alert("名额应为正整数");
    return
}

 

posted @ 2019-10-29 14:34  Fourteen  阅读(35024)  评论(0编辑  收藏  举报