【问题标题】:Disable and change color of submit button in jQuery Steps在 jQuery 步骤中禁用和更改提交按钮的颜色
【发布时间】:2017-02-08 18:25:24
【问题描述】:

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

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

但这并没有奏效。当我单击按钮时,它不会禁用按钮或更改外观。当我单击两次时,它会向我发送两封包含测试表格的电子邮件。

编辑:我不是要删除“输入”,而是要删除“提交”按钮,jQuery 文档将其列为“完成”。

我的完整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();
                            }*/
                        }
                })
                }

【问题讨论】:

标签: javascript jquery jquery-steps


【解决方案1】:

试试这个...

//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');
   } 
});

【讨论】:

  • 我需要为该完成按钮添加一个 ID - 感谢您为我指明正确的方向!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-09
  • 1970-01-01
  • 2012-12-19
  • 2011-05-22
  • 1970-01-01
相关资源
最近更新 更多