Jquery验证在工作1周后今天早上开始失败

时间:2015-03-05 12:18:48

标签: jquery html forms

我设置了这个代码,一切都工作正常一个星期,今天早上随机开始失败,但我没有看到我的代码有任何错误..任何人都可以告诉我,如果我错过了什么或解释为什么我会得到错误..

表格代码:

<div class="subscription-form">
    <form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="subscription-form">
        Name:
        <input type="text" class="form-control" name="subscription_firstname" id="subscription_firstname" placeholder="First Name" required>
        <span style="color:red; font-size:small":>*</span>
        Last Name:
        <input type="text" class="form-control" name="subscription_lastname" id="subscription_lastname" placeholder="Last Name" required>
        <span style="color:red; font-size:small":>*</span>
        Email:
        <input type="email" class="form-control" name="subscription_email" id="subscription_email" placeholder="Email Address" >
        Phone Number:
        <input type="text" class="form-control" name="subscription_phone" id="subscription_phone" placeholder="Phone Number" >
        Municipality:
        <input type="text" class="form-control" name="subscription_municipality" id="subscription_municipality" placeholder="Municipality" required>
        <span style="color:red; font-size:small":>*</span>
        Zip Code:
        <input type="text" class="form-control" name="subscription_zip" id="subscription_zip" placeholder="Zip Code" required>
        <span style="color:red; font-size:small":>*</span>
        <p style="color:red; font-size:small":>
            <i>* campos mandatorios.</i>
        </p>
        <input type="submit" class="btn btn-default submit-btn" name="submit-subscription-btn" value="Submit">
    </form>
    <div class="success-sf">
        <p>
            <i class="fa fa-envelope"></i> Gracias, su mensaje ha sido enviado
        </p>
    </div>
    <div class="error-sf">
        <p>
            <i class="fa fa-exclamation-triangle"></i> Hubo un problema sometiendo la forma, intente refrescando la página y sometiendo la forma nuevamente.
        </p>
    </div>
</div>

jQuery的:

$('#subscription-form').validate({
    rules: {
        subscription_firstname: {
            required: true,
            minlength: 2
        },
        subscription_lastname: {
            required: true,
            minlength: 2
        },
        subscription_municipality: {
            required: true,
            minlength: 2
        },
        subscription_zip: {
            required: true,
            minlength: 5
        }
    },
    messages: {
        subscription_firstname: "<i class='fa fa-exclamation-triangle'></i>Please specify your firstname.",
        subscription_lastname: "<i class='fa fa-exclamation-triangle'></i>Please specify your lastname.",
        subscription_municipality: "<i class='fa fa-exclamation-triangle'></i>Please specify your municipality.",
        subscription_zip: "<i class='fa fa-exclamation-triangle'></i>Please enter your Zip Code."
    },
    submitHandler: function(form) {
        $(form).ajaxSubmit({
            type: "POST",
            data: $(form).serialize(),
            url: "subscription-me.php",
            success: function() {
                $('#subscription-form :input').attr('disabled', 'disabled');
                $('#subscription-form').fadeTo("slow", 0.15, function() {
                    $(this).find(':input').attr('disabled', 'disabled');
                    $(this).find('label').css('cursor', 'default');
                    $('.success-sf').fadeIn();
                });
                $('#subscription-form')[0].reset();
            },
            error: function() {
                $('#subscription-form').fadeTo("slow", 0.15, function() {
                    $('.error-sf').fadeIn();
                });
            }
        });
    }
});

0 个答案:

没有答案