zoukankan      html  css  js  c++  java
  • 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;
    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,'')
  • 相关阅读:
    项目计划进度控制与资源管理
    读大道至简所思
    Java自学第三十二天
    Java自学第三十一天
    Java自学第三十天
    Java自学第二十九天
    Java自学第二十八天
    Java自学第二十七天
    Java自学第二十六天
    Java自学第二十五天
  • 原文地址:https://www.cnblogs.com/loveAline/p/9377362.html
Copyright © 2011-2022 走看看