2

http://www.gamereview.tv/email/

提交按钮只能使用一次。如果第一次尝试出现错误,则无法再次单击该按钮。测试时,输入无效的电子邮件。它显示提示,然后在您修复它之后,该按钮不再起作用。这是为什么?

JavaScript:

$('#submit').click(function() {
    $("#message").slideUp(200,function() {
        $('#message').hide();

        // Kick in Validation
        $('#name, #subject, #phone, #comments, #website, #verify, #email').triggerHandler("focusout");

        if ($('#contact mark.error').size()>0) {
            if(shake == "Yes") {
                $('#contact').effect('shake', { times:2 }, 75, function(){
                    $('#contact input.error:first, #contact textarea.error:first').focus();
                });
            } else $('#contact input.error:first, #contact textarea.error:first').focus();

            return false;
        }

    });
});

$('#contactform').submit(function(){

    if ($('#contact mark.error').size()>0) {
        if(shake == "Yes") {
        $('#contact').effect('shake', { times:2 }, 75);
        }
        return false;
    }

    var action = $(this).attr('action');

    $('#submit')
        .after('<img src="assets/ajax-loader.gif" class="loader" />')
        .attr('disabled','disabled');

    $.post(action, {
        name: $('#name').val(),
        email: $('#email').val(),
        phone: $('#phone').val(),
        website: $('#website').val(),
        subject: $('#subject').val(),
        comments: $('#comments').val(),
        verify: $('#verify').val()
    },
        function(data){
            $('#message').html( data );
            $('#message').slideDown();
            $('#contactform img.loader').fadeOut('slow',function(){$(this).remove()});
            $('#contactform #submit').attr('disabled','');
            if(data.match('success') != null) $('#contactform').slideUp('slow');

        }
    );

    return false;

});
4

1 回答 1

1

您的代码禁用了提交按钮,只有在发布成功时才重新启用它。

于 2012-10-28T04:05:57.140 回答