input輸入框正則驗證全是數字且只能輸入大於1小於90的數字

html-------css

<div class="validity_input">
<input type="text" class="videoDay" value={{queryList}} onkeyup="value=value.replace(/[^\d]/g,'')"placeholder="有效期1-90天" maxlength="2">
<div class="validity_color">天</div>
 
</div>
<span class="hintMessagedata">請輸入1-90之內的數字</span>
js----------
// 獲取焦點
$(".videoDay").focus(function(){
$(this).parent().siblings(".hintMessagedata").show();
});
$(".videoDay").blur(function(){
$(this).parent().siblings(".hintMessagedata").hide();
var otherPrice =$('.videoDay').val();
if(otherPrice<=0){
$('.videoDay').val('1')
}else if(otherPrice>=90){
$('.videoDay').val('90')
}
if(otherPrice.charAt(0) =="0"){
$('.videoDay').val('1')
}
 
});
css--------
.hintMessagedata {
display: none;
position: absolute;
top:-34px;
left: 24%;
z-index: 999;
width: 315px;
height: 28px;
color: #0099ff;
background: #fff;
text-align: center;
line-height: 28px;
font-size: 12px;
border: 1px solid #ccc;
opacity: 0.9;
filter: alpha(opacity=90);
}
----------------
 
驗證全是數字的正則replace(/[^\d]/g,'')
相關文章
相關標籤/搜索