Enable/Disable Submit Button Form - JQUERY + HTML

<!-- HTML --> <div class="form-group margin-top-50 text-right"> <button type="button" id="submitBtn" class="lp-secondary-btn btn btn-first-hover" onclick="validate_investor_register();">Subm</button> </div> function save_investor(){ $('#submitBtn') .html('Submit <i class="fa fa-spinner fa-spin"></i>') .attr('disabled','disabled'); $.post('investor/save.cfm?ck=' + Math.random() + '&ajax=1', $('#investor_register_form').serialize()) .success(function(data){ // Parse JSON returned by the SAVE m_result = JSON.parse(data); // If successful (ie Email not registered yet) if(m_result.result == 1){ // Success message toastr.success(m_result.msg, m_result.title); // Redirect to welcome confirmation page window.location.href = 'welcome'; } else{ // Renable the submit button on the form $('#submitBtn').html('Submit').removeAttr('disabled'); toastr.error(m_result.msg, m_result.title); } }) .error(function(data){ toastr.error(error_msg); }) .complete(function(data){ }); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.