<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 如何使用weui.topTips驗(yàn)證數(shù)據(jù)

            這篇文章主要為大家展示了“如何使用weui.topTips驗(yàn)證數(shù)據(jù)”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“如何使用weui.topTips驗(yàn)證數(shù)據(jù)”這篇文章吧。

            成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比大冶網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式大冶網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋大冶地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。

            場景一、有一個輸入金額的場景,這個金額需要驗(yàn)證,驗(yàn)證說明如下:

            不能為空格;

            不能為0;

            不能為漢字;

            不能為其它字符;

            不能大于200;

            唯一可以的是,只有輸入3~199之間的數(shù)字,下面的確定按鈕才會顯示,否則,隱藏這個按鈕。

            HTML:

            <!--醫(yī)生問診金額-->
                    <div class="weui-jiaj-panel">
                      <div class="weui-jiaj-money-box dialog js_show">
                        <div class="weui-jiaj-money-box-btn">
            
                        </div>
                        <div class="weui-jiaj-money-box-three">
                          <div class="weui-flex__item">
                            <a id="showMoney" href="javascript:;" rel="external nofollow" class="weui-btn weui-btn_mini weui-btn_default">其它</a>
                          </div>
                        </div>
                      </div>
                    </div>
                    <!--其它金額-->
                    <div class="weui_dialog_alert" id="showMoneyDialog" >
                      <div class="weui_mask"></div>
                      <div class="weui_dialog">
                        <div class="weui_dialog_hd"><strong class="weui_dialog_title">其它金額</strong></div>
                        <div class="weui_dialog_bd">
                          <div class="weui-jiaj-dialog-panel">
                            <div class="weui-cell">
                              <div class="weui-cell__bd">
                                <input id="dialogPrice" type="text" required class="weui-input" placeholder="¥10" />
                              </div>
                            </div>
                          </div>
                        </div>
                        <div class="weui_dialog_ft">
                          <div id="otherPriceBtn" class="weui_btn_dialog primary">確定</div>
                        </div>
                      </div>
                    </div>

            JS:

            <script>
                  //設(shè)置其它金額
                  var doctorPrices = [{
                    "doctorPrice": "5"
                  }, {
                    "doctorPrice": "10"
                  }, {
                    "doctorPrice": "15"
                  }, {
                    "doctorPrice": "20"
                  }, {
                    "doctorPrice": "30"
                  }, {
                    "doctorPrice": "60"
                  }];
            
                  var userId = $.cookie('doctorId');
            
                  $(function() {
                    selectedPrice();
                  });
            
                  var page = $('.page'); //頂層div
                  var panel = page.find('weui-jiaj-panel');
            
                  function selectedPrice() {
                    var $titleHtml = '';
                    for(var a = 0; a < doctorPrices.length; a++) {
                      var priceName = doctorPrices[a].doctorPrice;
                      //點(diǎn)周weui_btn_dialog隱藏
                      $titleHtml += '<button class="price_btn weui-btn weui-btn_mini weui-btn_warn"' + 'name=' + priceName + '>' + priceName + '</button>';
                      $('.price_btn').css('margin', '5px');
                    }
                    $('.weui-jiaj-money-box-btn').append($titleHtml);
            
                    //選擇金額
                    $('.price_btn').click(function() {
                      var titleValue = $(this).attr('name'); //$(this)表示獲取當(dāng)前被點(diǎn)擊元素的name值
            
                      var data = {
                        userId: userId,
                        price: titleValue
                      };
            
                      data = JSON.stringify(data);
                      $.ajax({
                        data: {},
                        dataType: 'json',
                        type: "post",
                        url: postDoctorPrice().replace("{userId}", userId).replace("{price}", titleValue),
                        contentType: 'application/json; charset=utf-8',
                        success: function(data) {
                          if(data && data.status == '200') {
                            weui.topTips('提交成功');
                          }
                        },
                        error: function(data) {
                          location.href = 'doctor_wode.html';
                        }
                      });
                    });
            
                    //其它金額
                    $('#otherPriceBtn').on('click', function(e) {
                      var otherPrice = $('#dialogPrice').val();
                      otherPrice = parseInt(otherPrice);
            
                      otherPrice = otherPrice.toString();
                      console.log("其它金額" + otherPrice);
                      var data = {
                        userId: userId,
                        price: otherPrice
                      };
            
                      data = JSON.stringify(data);
                      $.ajax({
                        data: {},
                        dataType: 'json',
                        type: "post",
                        url: postDoctorPrice().replace("{userId}", userId).replace("{price}", otherPrice), //post 時url帶參數(shù)
                        contentType: 'application/json; charset=utf-8',
                        success: function(data) {
                          if(data && data.status == '200') {
                            weui.topTips('設(shè)置成功!');
                          }
                        },
                        error: function(data) {
                          location.href = 'doctor_wode.html';
                        }
                      });
                    });
                  }
            
                  //驗(yàn)證
                  $('input').on('blur',function(){
                    var value = this.value;
                    var regChinese = new RegExp("[\\u4E00-\\u9FFF]+","g");
                    //字符串不能為空
                    if(value.length == 0) {
                      $('#otherPriceBtn').hide();
                      weui.topTips('不能為空');
                      //字符串是否為“空”字符即用戶輸入了空格
                    }else if(value.replace(/(^s*)|(s*$)/g, "").length ==0){
                      $('#otherPriceBtn').hide();
                      weui.topTips('不能為空');
                      //字符串是否為空或者全部都是空格
                    }else if(value == null){
                      $('#otherPriceBtn').hide();
                      weui.topTips('不能為null');
                      //字符串是否為漢字
                    }else if(regChinese.test(value)){
                      $('#otherPriceBtn').hide();
                      weui.topTips('不能輸入漢字');
                      //字符串不能為0
                    }else if(parseInt(value) == 0){
                      $('#otherPriceBtn').hide();
                      weui.topTips('不能為0');
                      //不能大于200
                    }else if(parseInt(value) > 200){
                      $('#otherPriceBtn').hide();
                      weui.topTips('自定義金額不能大于200元');
                      //自定義金額只能是數(shù)字
                    }else if(typeof(parseInt(value))){
                      $('#otherPriceBtn').show();
                    }
                  })
                </script>

            如何使用weui.topTips驗(yàn)證數(shù)據(jù)如何使用weui.topTips驗(yàn)證數(shù)據(jù)

            場景二、所有違反規(guī)距的都有信息提示,但是“確定”按鈕不隱藏,只是刪除它的click事件,只有符合條件的才可以跳轉(zhuǎn)

            //驗(yàn)證
                  $('input').on('blur', function() {
                    var value = this.value;
                    var regChinese = new RegExp("[\\u4E00-\\u9FFF]+", "g"); //漢語
                    var specialSymbol =/[`~!@#$%^&*_+<>{}\/'[\]]/im; //特殊符號
                    //字符串不能為空
                    if(value.length == 0) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('不能為空,請重新輸入');
                      }, 500);
                      //字符串是否為“空”字符即用戶輸入了空格
                    } else if(value.replace(/(^s*)|(s*$)/g, "").length == 0) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('不能為空,請重新輸入');
                      }, 500);
                      //字符串是否為空或者全部都是空格
                    } else if(value == null) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('不能為空,請重新輸入');
                      }, 500);
                      //字符串是否為漢字
                    } else if(regChinese.test(value)) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('不能輸入漢字,請重新輸入');
                      }, 500);
                      //字符串不能為0
                    } else if(parseInt(value) == 0) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('不能為0,請重新輸入');
                      }, 500);
                      //小于3
                    } else if(parseInt(value) < 4) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('自定義金額不能小于3,請重新輸入');
                      }, 500);
                      //不能大于200
                    } else if(parseInt(value) > 200) {
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('自定義金額不能大于200,請重新輸入');
                      }, 500);
                    } else if(specialSymbol.test(value)){
                      //禁止輸入特殊字符
                      $('#otherPriceBtn').unbind('click');
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('不可輸入!@#¥%……&*特殊字符!');
                      }, 500);
                      //自定義金額只能是數(shù)字
                    } else if(typeof(parseInt(value))) {
                      setTimeout(function() {
                        $('.hide-description').css('display', 'block').text('你設(shè)置的金額為' + value);
                      }, 500);
                      //其它金額
                      $('#otherPriceBtn').on('click', function(e) {
                        var otherPrice = $('#dialogPrice').val();
                        otherPrice = parseInt(otherPrice);
            
                        otherPrice = otherPrice.toString();
                        console.log("其它金額" + otherPrice);
                        var data = {
                          userId: userId,
                          price: otherPrice
                        };
            
                        data = JSON.stringify(data);
                        $.ajax({
                          data: {},
                          dataType: 'json',
                          type: "post",
                          url: postDoctorPrice().replace("{userId}", userId).replace("{price}", otherPrice), //post 時url帶參數(shù)
                          contentType: 'application/json; charset=utf-8',
                          success: function(data) {
                            if(data && data.status == '200') {
                              weui.topTips('設(shè)置成功!');
                            }
                          },
                          error: function(data) {
                            location.href = 'doctor_wode.html';
                          }
                        });
                      });
                    }
                  })

            以上是“如何使用weui.topTips驗(yàn)證數(shù)據(jù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

            網(wǎng)站題目:如何使用weui.topTips驗(yàn)證數(shù)據(jù)
            網(wǎng)頁路徑:http://www.jbt999.com/article4/ihsdoe.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、服務(wù)器托管做網(wǎng)站、標(biāo)簽優(yōu)化、面包屑導(dǎo)航網(wǎng)頁設(shè)計公司

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

            成都做網(wǎng)站

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 久草国产在线视频 | 在线免费观看A∨ | 欧美成人性爱在线视频 | 91久久婷婷国产麻豆精品电影.co | 插逼免费|