简体   繁体   中英

jQuery enable/disable submit button

I am using jquery to disable the submit button and the registration. I want to remove the bank detail, account number, and ifsc code. But when I remove those fields, the submit button not click(hit). I want to remove disabled prevention. please help me out

function registerMember() {
    e.preventDefault(e);
    $('#nxt3dddd').prop('disabled',true);
    var flag="yes";

    $('.inp').each(function(){
        var a=$(this).val();
        if(a==""){
            flag="no";
            $(this).css('border','1px solid red');
            $('#nxt3dddd').prop('disabled',false);
        }else{
            $(this).css('border','1px solid #d2d6de');
        }
    });
}

In submit button I am using the following:

<div class="col-xs-6" style="text-align:right;margin:inherit">
   <button type="submit" id="nxt3dddd" class="btn btn-primary btn-block btn-flat" style="width:100px;float:right">Submit</button> 
</div>

You are doesn't call function registerMember() in onclick() event of button and add a input text having named inp

 function registerMember() { $('#nxt3dddd').prop('disabled',true); var flag="yes"; $('.inp').each(function(){ var a=$(this).val(); if(a==""){ flag="no"; $(this).css('border','1px solid red'); $('#nxt3dddd').prop('disabled',false); }else{ $(this).css('border','1px solid #d2d6de'); } }); }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="col-xs-6" style="text-align:right;margin:inherit"> <input class="inp" type="text" /> <button type="submit" id="nxt3dddd" class="btn btn-primary btn-block btn-flat" style="width:100px;float:right" onclick="registerMember()">Submit</button> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM