PHP 页面上的多个联系表单 - 无需页面刷新
是否可以在一个页面上包含多个联系表单,并且仍然可以在不刷新页面的情况下验证和发送电子邮件。
我已经使用了下面的教程,但如果明显复制,这仍然只能验证原始表单...
http://www.ajaxfreak.com/2009/12/03/submit-a-form-without-page-refresh-using-jquery/
我可以为每个所需的表单复制 JS 等,但必须有一种更有效的方法来做到这一点,也许可以使用隐藏值和隐藏值。表格ID?
有人有什么想法吗?
谢谢
Is it possible to have multiple contact forms on one page and still validate and send an email without the page refreshing.
I have used the tutorial below but if copied obviously this still only validates the original form...
http://www.ajaxfreak.com/2009/12/03/submit-a-form-without-page-refresh-using-jquery/
I could copy the JS etc for each of the required forms but there must be a more efficient way of doing this, maybe with hidden values & form ids?.
Anybody have any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这当然是可能的,不幸的是演示使用 ID 手动构建数据字符串,这并不容易转换为多种形式。在表单上使用 .serialize() 方法会方便得多。
以下(简化的)示例适用于页面上具有“ajax”类的任意数量的表单。具有“required”类的输入元素将首先检查值,如果缺少,将应用背景红色:
It is certainly possible, unfortunately the demo manually builds the data string manually using IDs, which doesn't make it easy to convert to multiple forms. It would be much more convenient to use the .serialize() method on the form.
The following (simplified) example should work for any number of forms on the page that have the class "ajax". Input elements with the 'required' class will be checked for a value first, and will have background red color applied if it's missing: