Jquery表单插件未提交到进程页面

时间:2012-08-22 17:34:36

标签: php jquery html ajax forms

我有一个使用Jquery表单插件的基本联系表单。我无法使用插件提交它。它只提交我添加一个php include到process.php。

使用Javascript:

 $(document).ready(function() { 
     $("#contact").validate({
         submitHandler: function(form) {
             $(form).ajaxSubmit({
                 url:"process.php",
                 type:"post",
             });
         }
     });
 });

这是我的联系表格:

 <form id="contact" method="post" name="validation" action="contact.php" onsubmit="return validateForm();">
     <fieldset> 

         <label for="name">Name</label>
         <input type="text" name="name" placeholder="Full Name" title="Enter your name" class="required">

         <label for="email">E-mail</label>
         <input type="email" name="email" placeholder="yourname@domain.com" title="Enter your e-mail address" class="required email">

         <label for="phone">Phone</label>
         <input type="tel" name="phone" placeholder="ex. (555) 555-5555">

         <label for="message">Question/Comment</label>
         <textarea name="message"></textarea>

         <input type="submit" name="submitted" class="button" id="submit" value="Send Message"     />

     </fieldset>
 </form>

Process.php

   <?php
   function GetHeaders()
   {
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: Company Name<info@companyname.com>' . "\r\n";
    return $headers;
   }
   // Get Data  
   $name = strip_tags($_POST['name']);
   $email = strip_tags($_POST['email']);
   $phone = strip_tags($_POST['phone']);
   $message = strip_tags($_POST['message']);
    // Send Message
    $headers = GetHeaders();
    $intro = "\"Thank you for contacting Company Name. We are very interested in assessing your situation and will be in touch as soon possible.\" <br />
    <br/>
      Best Regards,<br/>
    <br/>
      Company<br/>
    ";
 mail($email, "RE: Contact Form Submission", $intro, $headers);      
 ?>

感谢您提前提供任何帮助。

1 个答案:

答案 0 :(得分:0)

您需要从表单属性中删除onsubmit="return validateForm();。您已经在查询就绪函数中使用$("#contact").validate({进行验证

另外,您的表单似乎是提交给contact.php,而不是process.php

action="contact.php"