第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

jQuery如果輸入字段為空,如何禁用單擊功能

jQuery如果輸入字段為空,如何禁用單擊功能

12345678_0001 2019-04-17 14:15:26
И有一些步驟卡,我有輸入字段。對于每張卡,我有一個(gè)“下一步”按鈕,用于更改視圖。但是如果表單中有空輸入字段,我想阻止此按鈕。碼:var $currentCard, $nextCard, $prevCard;var animationEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';var operationName = ["Order number", "Oparation barcode", "Nest number", "Layers number", "Cycles number"];$('.next').on('click', function (e) {        e.preventDefault();        $currentCard = $(this).parent().parent();        $nextCard = $currentCard.next();        $('#bar li').eq($('.card').index($nextCard)).addClass('active');        var inAnimation = 'animated slideInLeft';        $currentCard.hide();        $nextCard            .show()            .addClass(inAnimation)            .one(animationEvents, function () {                $(this).removeClass(inAnimation);            });});$('.prev').on('click', function (e) {    e.preventDefault();    $currentCard = $(this).parent().parent();    $prevCard = $currentCard.prev();    $('#bar li').eq($('.card').index($currentCard)).removeClass('active');    var inAnimation = 'animated slideInRight';    $currentCard.hide();    $prevCard        .show()        .addClass(inAnimation)        .one(animationEvents, function () {            $(this).removeClass(inAnimation);        });});.title {    margin-bottom: 30px;    color: #020304;}.card {    max-width: 500px;    width: 90%;    background: white;    margin: 50px ;    padding: 20px 30px;    border-radius: 2px;    -webkit-animation-duration: 0.2s;    animation-duration: 0.2s;}.cardTitle {    text-align: center;    text-transform: uppercase;    margin: 0;}.cardText {    margin: 25px 0 40px 0;    color: grey;    text-align:center;}.card:not(:first-of-type) {    display: none;}.actions {    text-align: center;}因此,您可以看到我有一個(gè)函數(shù)來檢查某個(gè)輸入字段是否為空,當(dāng)我按下Next時(shí),它將轉(zhuǎn)到下一頁。我需要的是按下“ 下一步”按鈕以驗(yàn)證輸入字段是否已填充,然后再繼續(xù)。
查看完整描述

2 回答

?
瀟瀟雨雨

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個(gè)贊

我添加了這個(gè)jQuery代碼:


if($('.POBarcode').is(":visible")){

  if($('.POBarcode').val().length == 0) return false;

}

if($('.Operation_barcode').is(":visible")){

  if($('.Operation_barcode').val().length == 0) return false;

}

我還在class以下元素中添加了一個(gè)


<input type="text" class="POBarcode" placeholder="PO barcode">

<input type="text" placeholder="Operation barcode" class="Operation_barcode">

現(xiàn)在你不能按下一個(gè)按鈕之前input是visible有一個(gè)value。


工作演示


查看完整回答
反對 回復(fù) 2019-05-17
?
POPMUISE

TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊

你可以在下一次點(diǎn)擊中做這樣的事情:

if ($('input', $currentCard).val() === '' && $(this).text() !== 'Register new PO') {
   return;}


查看完整回答
反對 回復(fù) 2019-05-17
  • 2 回答
  • 0 關(guān)注
  • 555 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號