我想将验证规则添加到联系人窗体的电子邮件部分,以便该字段不是空白并且是有效的电子邮件地址。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