状态更改禁用后,Internet Explorer输入字段将不起作用 - >启用

时间:2013-02-22 10:34:21

标签: jquery html internet-explorer input

我实际上正在尝试修复某种类型的IE BUG。

我创建了一个带有policys复选框和提交按钮的html表单。 只要策略复选框未“选中”,就会禁用“提交”按钮。 这一切都是我用jquery完成的。

奇怪的是,它在chrome,ff和safari中都运行良好,但在按钮失去“禁用”状态后的IE中,它停止工作。它仍然显示为链接,但是当我点击它时,没有任何反应。

这是我用来禁用和启用按钮的脚本:

/* Webform/Newsletter Checkbox + Mailfield validation */

var mailCheckbox = $('#webform-component-e-mail #edit-submitted-e-mail-newsletter-selection div').size();
var copyCheckbox = $('.webform-client-form input#edit-submitted-email-abmeldung-1, .webform-client-form #webform-component-datenschutzbestimmungen input#edit-submitted-datenschutzbestimmungen-1').size();


if(mailCheckbox > 1) {
        var submitButton = $('.webform-client-form #edit-actions').html();
            $('.webform-client-form #edit-actions').html('<input disabled type="submit" class="form-submit-disabled" value="Bestellen" name="op" id="edit-submit">')
            $('body').mousemove(function() {
        if ($('#edit-submitted-e-mail-newsletter-selection .form-checkbox').is(':checked') && $('#webform-component-email-abmeldung .form-checkbox').is(':checked') && $('#webform-component-e-mail #edit-submitted-e-mail-newsletter-email-address').val() != "" ) {
            $('.node-webform .webform-client-form #edit-actions').html('<input type="submit" class="form-submit" name="op" value="Absenden" id="edit-submit">')
            $('.node-newsletter-anmeldung .webform-client-form #edit-actions').html('<input type="submit" class="form-submit" name="op" value="Bestellen" id="edit-submit">')
        }
        else {
            $('.node-webform .webform-client-form #edit-actions').html('<input disabled type="submit" class="form-submit-disabled" value="Absenden" name="op" id="edit-submit">')
            $('.node-newsletter-anmeldung .webform-client-form #edit-actions').html('<input disabled type="submit" class="form-submit-disabled" value="Bestellen" name="op" id="edit-submit">')             
        }
        });
}
else {
        var submitButton = $('.webform-client-form #edit-actions').html();
            $('.webform-client-form #edit-actions').html('<input disabled type="submit" class="form-submit-disabled" value="Bestellen" name="op" id="edit-submit">')
            $('body').mousemove(function() {
        if ($('#webform-component-email-abmeldung .form-checkbox, #webform-component-datenschutzbestimmungen .form-checkbox').is(':checked') && $('#webform-component-e-mail #edit-submitted-e-mail-newsletter-email-address, #webform-component-webform-kontakt-email #edit-submitted-webform-kontakt-email').val() != "") {
            $('.node-webform .webform-client-form #edit-actions').html('<input type="submit" class="form-submit" name="op" value="Absenden" id="edit-submit">')
            $('.node-newsletter-anmeldung .webform-client-form #edit-actions').html('<input type="submit" class="form-submit" name="op" value="Bestellen" id="edit-submit">')
        }
        else {
            $('.node-webform .webform-client-form #edit-actions').html('<input disabled type="submit" class="form-submit-disabled" value="Absenden" name="op" id="edit-submit">')
            $('.node-newsletter-anmeldung .webform-client-form #edit-actions').html('<input disabled type="submit" class="form-submit-disabled" value="Bestellen" name="op" id="edit-submit">')
        }
        });
}

$('body.node-type-newsletter-anmeldung #edit-submit').attr('value', 'Bestellen');
$('body.node-webform #edit-submit').attr('value', 'Absenden');

知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

我自己开始工作,对于遇到这个问题的其他人来说,这就是我解决它的方法:

/* Webform/Newsletter Checkbox + Mailfield validation */

    var mailCheckbox = $('#webform-component-e-mail #edit-submitted-e-mail-newsletter-selection div').size();
    var copyCheckbox = $('.webform-client-form input#edit-submitted-email-abmeldung-1, .webform-client-form #webform-component-datenschutzbestimmungen input#edit-submitted-datenschutzbestimmungen-1').size();

    $('.webform-client-form #edit-actions input').addClass('button_active');
    $('.webform-client-form #edit-actions').append('<div class="button_inactive"><input disabled type="submit" class="form-submit-disabled" value="Bestellen" name="op" id="edit-submit"></div>')

    if(mailCheckbox > 1) {
            var submitButton = $('.webform-client-form #edit-actions').html();
                $('.webform-client-form #edit-actions .button_active').css('display','none');
                $('body').mousemove(function() {
            if ($('#edit-submitted-e-mail-newsletter-selection .form-checkbox').is(':checked') && $('#webform-component-email-abmeldung .form-checkbox').is(':checked') && $('#webform-component-e-mail #edit-submitted-e-mail-newsletter-email-address').val() != "" ) {
                $('.node-webform .webform-client-form #edit-actions .button_active').css('display', 'block')
                $('.node-webform .webform-client-form #edit-actions .button_inactive').css('display', 'none')
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_active').css('display', 'block')
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_inactive').css('display', 'none')
            }
            else {
                $('.node-webform .webform-client-form #edit-actions .button_active').css('display','none');
                $('.node-webform .webform-client-form #edit-actions .button_inactive').css('display','block');
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_active').css('display','none');
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_inactive').css('display','block');
            }
            });
    }
    else {
            var submitButton = $('.webform-client-form #edit-actions').html();
                $('.webform-client-form #edit-actions .button_active').css('display','none');
                $('body').mousemove(function() {
            if ($('#webform-component-email-abmeldung .form-checkbox, #webform-component-datenschutzbestimmungen .form-checkbox').is(':checked') && $('#webform-component-e-mail #edit-submitted-e-mail-newsletter-email-address, #webform-component-webform-kontakt-email #edit-submitted-webform-kontakt-email').val() != "") {
                $('.node-webform .webform-client-form #edit-actions .button_active').css('display', 'block')
                $('.node-webform .webform-client-form #edit-actions .button_inactive').css('display', 'none')
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_active').css('display', 'block')
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_inactive').css('display', 'none')
            }
            else {
                $('.node-webform .webform-client-form #edit-actions .button_active').css('display','none');
                $('.node-webform .webform-client-form #edit-actions .button_inactive').css('display','block');
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_active').css('display','none');
                $('.node-newsletter-anmeldung .webform-client-form #edit-actions .button_inactive').css('display','block');
            }
            });
    }