在jQuery步骤中禁用并更改提交按钮的颜色 [英] Disable and change color of submit button in jQuery Steps

查看:214
本文介绍了在jQuery步骤中禁用并更改提交按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过类似的问题,但到目前为止,没有解决方案.我正在使用jQuery Steps表单,并且尝试禁用单击提交按钮并更改外观.我尝试使用:

I've looked at similar questions but no solutions have worked so far. I'm using a jQuery Steps form and I'm trying to disable the submit button on click and also change the appearance. I've tried using:

$('finish').attr('disabled',true);

但是那没有用.当我单击按钮时,它不会禁用按钮或更改外观.当我单击两次时,它会向我发送两封带有测试表格的电子邮件.

But that hasn't worked. When I click the button, it doesn't disable the button or change the appearance. When I click twice, it sends me two emails with the test form.

我不是要删除输入",而是要删除提交"按钮,jQuery文档将其列为完成".

I am not trying to remove an "input," I'm trying to remove a "submit" button, which the jQuery documentation lists as "finish".

我的完整JS在下面.

$(function(){
            $("#smart-form").steps({
                bodyTag: "fieldset",
                headerTag: "h2",
                bodyTag: "fieldset",
                transitionEffect: "fade",
                titleTemplate: "<span class='number'>#index#</span> #title#",
                labels: {
                    finish: "Submit Form",
                    next: "Continue",
                    previous: "Go Back",
                    loading: "Loading..." 
                },
                onStepChanging: function (event, currentIndex, newIndex){
                    if (currentIndex > newIndex){return true; }
                    var form = $(this);
                    if (currentIndex < newIndex){}
                    return form.valid();
                },
                onStepChanged: function (event, currentIndex, priorIndex){
                },
                onFinishing: function (event, currentIndex){
                    var form = $(this);
                    $('finish').attr('disabled',true);
                    form.validate().settings.ignore = ":disabled";
                    return form.valid();


                },
                onFinished: function (event, currentIndex){
                    var form = $(this);
                             $(form).ajaxSubmit({
                        target:'.result',              
                        beforeSubmit:function(){ 
                            //$('.form-footer').addClass('progress');
                        },
                        error:function(){
                            //$('.form-footer').removeClass('progress');
                        },
                        success:function(){
                            $('.alert-success').show().delay(10000).fadeOut();
                            //$("#wizard").steps('done');
                            //$("#smart-form").steps('reset');
                            //setCurrentIndex();
                            //startIndex: 0
                            //reset();
                            /*$('.form-footer').removeClass('progress');
                            $('.alert-success').show().delay(10000).fadeOut();
                            $('.field').removeClass("state-error, state-success");
                            if( $('.alert-error').length == 0){
                            $('#smart-form').resetForm();
                            reloadCaptcha();
                            }*/
                        }
                })
                }

推荐答案

尝试一下...

//Applying colour for finish button
var result = $('ul[aria-label=Pagination]').children().find('a');
$(result).each(function ()  { 
   if ($(this).text() == 'Finish') {
       $(this).attr('disabled', true);
       $(this).css('background', 'green');
   } 
});

这篇关于在jQuery步骤中禁用并更改提交按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆