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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM