gpt4 book ai didi

php - Jquery 和联系表单验证

转载 作者:行者123 更新时间:2023-12-01 08:22:10 25 4
gpt4 key购买 nike

我正在尝试将验证规则添加到联系表单的电子邮件部分,以便该字段不为空并且是有效的电子邮件地址。

我怎样才能实现这个目标?

我还想添加一个在提交表单后发送给用户的自动响应?

$("#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@test.com">
<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>

请注意,我没有创建此代码,也不太熟悉它,我们有一家开发公司创建了我们的网站,我只是想扩展它以满足我们的需求,我只需要一点指导。

最佳答案

看看http://unwrongest.com/projects/valid8/ (还有大约 500 个其他“表单验证”插件)。这是我最喜欢的,因为它非常纤薄且简单。

关于php - Jquery 和联系表单验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6708673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com