input输入框正则验证全是数字且只能输入大于1小于90的数字

html-------

<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,'')

猜你喜欢

转载自www.cnblogs.com/loveAline/p/9377362.html
今日推荐