我想將驗證規則添加到聯繫人窗體的電子郵件部分,以便該字段不是空白並且是有效的電子郵件地址。Jquery和聯繫表單驗證
我該如何做到這一點?
我還想添加表單提交後發送給用戶的自動回覆嗎?
$("#ContactForm").submit(function() {
$.ajax({
type: "POST",
url: "{homepage}mailer/mailer.php",
data: $(this).serialize(),
success: function(data){
$('#fancybox-content #quote_box #ContactForm').html('<div style="padding-top: 15px; text-align:center;">Message Sent! Thank you.</div>');
setTimeout(function(){
$.fancybox.close();
},3500);
}
});
});
<form id="ContactForm" name="ContactForm" action="{homepage}mailer/mailer.php" method="post">
<input type="hidden" name="_sendto" value="[email protected]">
<input type="hidden" name="_subject" value="Quote Request">
<label for="name">Name</label><input type="text" name="name"><br>
<label for="title">Title</label><input type="text" name="title"><br>
<label for="customer_segment">Customer segment</label><input type="text" id="customer_segment" name="customer_segment" value=""><br>
<label for="company">Company</label><input type="text" name="company"><br>
<label for="email">Email</label><input type="text" name="email"><br>
<label for="phone">Phone</label><input type="text" name="phone"><br>
<label for="city">City</label><input type="text" name="city"><br>
<label for="state">State</label><input type="text" name="state"><br>
<label for="country">Country</label><input type="text" name="country"><br>
<label for="contact_interested_in">Product interested in</label><input type="text" name="prod_inquiry" value="{exp:cookie_plus:get name="" parse="inward"}{exp:channel:entries entry_id="{cookie}"}{title}{/exp:channel:entries}{/exp:cookie_plus:get}"><br>
<label for="contact_preference">Contact preference</label>
<input class="radio" type="radio" name="contact_preference" value="Phone"> <span class="label">Phone</span>
<input class="radio" type="radio" name="contact_preference" value="Email"> <span class="label">Email</span><br>
<input id="button" type="submit" value="Submit" />
</form>
請注意,我沒有創建這個代碼不是很熟悉的話,我們有一個開發公司建立我們的網站,我只是試圖擴大它來滿足我們的需求,我只需要一點點的方向。
使用Jquery驗證插件http://docs.jquery.com/Plugins/Validation#List_of_built-in_Validation_methods。然後在你的成功創建一個div並添加一個成功的短語tit titan – Brad