zoukankan      html  css  js  c++  java
  • 获取select值及判断是否是数字

    代码片段

     1 <div class="container-fluid">
     2     <div class="row">
     3         <div class="col-md-6 col-md-offset-3">
     4             <div class="panel panel-default m-top">
     5                 <div class="panel-heading">添加</div>
     6                 <div class="panel-body">
     7                     <form method="" action="" class="form-horizontal">
     8                         <div class="form-group form-group-sm">
     9                             <label for="productNos" class="col-sm-4 control-label">名称:</label>
    10                             <div class="col-sm-4">
    11                                 <select name="productNo" id = "productNos" class="form-control">
    12                                     <option value="">--请选择--</option>
    13                                     <option value="010">动联</option>
    14                                     <option value="009">BBPOS</option>
    15                                     <option value="008">天喻</option>
    16                                     <option value="007">江苏怡丰</option>
    17                                     <option value="006">赢联</option>
    18                                     <option value="005">华中星(鼎合)</option>
    19                                     <option value="004">新大陆</option>
    20                                     <option value="003">智嘉</option>
    21                                     <option value="002">升腾</option>
    22                                     <option value="001">艾创</option>
    23                                 </select>
    24                             </div>
    25                             <div class="col-sm-4">
    26                                 <span class="msg1"></span>
    27                             </div>
    28                         </div>
    29                         <div class="form-group form-group-sm">
    30                             <label for="proNum" class="col-sm-4 control-label">数量:</label>
    31                             <div class="col-sm-4">
    32                                 <input type="text" id="proNum" name="proNum"  class="form-control" />
    33                             </div>
    34                             <div class="col-sm-4">
    35                                 <span class="msg2"></span>
    36                             </div>
    37                         </div>
    38                         <div class="col-sm-offset-4">
    39                             <button type="submit" class="btn btn-primary btn-sm" onclick="return create();">
    40                                 <i class="glyphicon glyphicon-saved"></i>
    41                                 <span>保存</span>
    42                             </button>
    43                             <button onclick="back();" class="btn btn-sm btn-danger" type="button">
    44                                 <i class="glyphicon glyphicon-remove-circle"></i>
    45                                 <span> 取消</span>
    46                             </button>
    47                         </div>
    48                     </form>
    49                 </div>
    50             </div>
    51         </div>
    52     </div>
    53 </div>
    54     
    55 <script type="text/javascript">
    56 function create(){
    57     var productNo = $("#productNos").val(); // 获取select 的value值
    58     if(productNo == ""){
    59         layer.msg("请选择厂家名称!
    ", {title: '提示框',icon:0,shade: [0.5],scrollbar: false});
    60         return false;
    61     }
    62     var proNum = $("#proNum").val();
    63     if(proNum == ""){
    64         layer.msg("请输入数量!
    ", {title: '提示框',icon:0,shade: [0.5],scrollbar: false});
    65         return false;
    66     }else{
    67         if(isNaN(proNum)){ // 如果是数字则返回 false 
    68             layer.msg("请输入数字!
    ", {title: '提示框',icon:0,shade: [0.5],scrollbar: false});
    69             return false;
    70         }
    71     }
    72 }
    73 </script>
  • 相关阅读:
    Windows常用命令
    Linux常用命令
    SpringBoot实现动态数据源切换及单库事务控制
    ArrayList与LinkedList
    java学习笔记之集合—ArrayList源码解析
    java学习笔记之反射—反射和工厂模式
    java学习笔记之反射—Class类实例化和对象的反射实例化
    java学习笔记之IO编程—对象序列化
    java学习笔记之IO编程—打印流和BufferedReader
    java学习笔记之IO编程—内存流、管道流、随机流
  • 原文地址:https://www.cnblogs.com/ljblog/p/7575210.html
Copyright © 2011-2022 走看看