花式盒形式没有弹出

时间:2016-01-14 06:11:39

标签: php forms fancybox

我是这个网站的新手所以请原谅我。这是我的表单代码。它突然冒出来了。突然间它停了下来。我们确实有ReCaptcha但我们可以在没有它的情况下提交表格。所以我们刚刚删除了recaptcha。

<form id="emailform" name="emailform" method="post" action="/post-email.php"     onSubmit="return ValidateRequiredFields();">
    <table width="100%" border="0" cellspacing="10" cellpadding="0" style="margin-left:20px" align="left">
        <tr>
            <td width="31%" align="left">Full Name:</td>
            <td width="69%" align="left">
                <label>
                    <input type="text" name="first_name" id="fname" />
                </label>
            </td>
        </tr>
        <tr>
            <td align="left">Email:</td>
            <td align="left">
                <label>
                    <input type="text" name="email2" id="email2" />
                </label>
            </td>
        </tr>
        <tr>
            <td align="left">Confirm Email:</td>
            <td align="left">
                <label>
                    <input type="text" name="confirmation_email" id="cemail" />
                </label>
            </td>
        </tr>
        <tr>
    </div>
</td>
</tr>
<tr>
    <td class="body-copy">&nbsp;</td>
    <td align="left">
        <label>
            <input type="submit" name="submit" id="submit" value="Submit" />                  
        </label>
    </td>
</tr>
</table>
</form>
</td>
<td width="400" align="center" valign="top"><h1><img src="/images/scarf-operation-shelter-supplies (2) b.jpg" width="339" height="368" alt="SCARF Pawsitive Happenings" /></h1></td>
</tr>
<tr>
    <td colspan="2" align="center" valign="top" bgcolor="#a5ddeb" height="10px"></td>
</tr>
</table>
</div>

<!-- basic fancybox setup -->
<script type="text/javascript">
    function validateEmail(email) { 
        var reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

        return reg.test(email);
    }

$(document).ready(function() {
    $(".modalbox").fancybox();
    $("#contact").submit(function() { return false; });
    $("#send").on("click", function(){
    var emailval  = $("#email").val();
    var msgval    = $("#msg").val();
    var msglen    = msgval.length;
    var mailvalid = validateEmail(emailval);

    if(mailvalid == false) {
        $("#email").addClass("error");
    }
    else if(mailvalid == true){
        $("#email").removeClass("error");
    }

    if(msglen < 4) {
        $("#msg").addClass("error");
    }
    else if(msglen >= 4){
        $("#msg").removeClass("error");
    }

    if(mailvalid == true && msglen >= 4) {
        // if both validate we attempt to send the e-mail
        // first we hide the submit btn so the user doesnt click twice
        $("#send").replaceWith("<em>sending...</em>");
        $("form").submit(function(event){ 
            $.ajax({
                    type: 'POST',
                    url: 'sendmessage.php',
                    data: $("#contact").serialize(),
                    success: function(data) {
                        if(data == "true") {
                            $("#contact").fadeOut("fast", function(){
                                $(this).before("<p><strong>Success! Your email has been sent, thanks :)</strong></p>");
                                setTimeout("$.fancybox.close()", 1000);
                            });
                        }
                    }
            });
        }
    });
});
</script>

0 个答案:

没有答案