【发布时间】:2015-03-25 15:39:30
【问题描述】:
我正在使用自定义 optin 表单。这是代码
<div class="form fix">
<p class="form-text">Fill This Out and See Your<br>Timeshare Report</p>
<form name="contactform" action="mail-script.php" method="POST">
<label for="fname">First Name:
<input type="text" name="fname" id="fname" />
</label>
<br>
<label for="lname">Last Name:
<input type="text" name="lname" id="lname" />
</label>
<br>
<label for="email">Email Address:
<input type="text" name="email" id="email" />
</label>
<br>
<label for="phone">Phone Number:
<input type="text" name="phone" id="phone" />
</label>
<br>
<label for="phone">Alternate Phone:
<input type="text" name="phone" id="aphone" />
</label>
<br>
<label for="resort">Resort Name:
<input type="text" name="resort" id="resort" />
</label>
<br>
<label for="amount">Amount Owed? $:
<input type="number" name="amount" id="amount" />
<p style="font-size: 12px !important;margin-top: -14px;padding-right: 30px;text-align:right;">If Paid Off Leave Zero, Else Put Amount</p>
</label>
<br>
<div class="checkbox">
<div class="check-text fix">
<p>I'm Considering To</p>
</div>
<div class="check-one fix">
<input type="checkbox" name="call" id="" value="sell" />Sell It
<br>
<input type="checkbox" name="call" id="" value="buy" />Buy It
<br>
<input type="checkbox" name="call" id="" value="rent " />Rent It
</div>
<div class="check-two fix">
<input type="checkbox" name="call" id="" value="cancel" />Cancel Mortgage
<br>
<input type="checkbox" name="call" id="" value="ownership" />End Ownership
<br>
<input type="checkbox" name="call" id="" value="give" />Give It Back
</div>
</div>
<p class="captcha">
<img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg'>
<br>
<label for='message'>Enter the code above here :</label>
<br>
<input id="6_letters_code" name="6_letters_code" type="text">
<br> <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
</p>
<input id="submit" type="submit" value="" />
<p class="submit-text">Ensure all fields are completed and correct, allowing you more benefits, while preventing abuse of our data.</p>
</form>
</div>
</div>
我想添加一个弹出 javascript 以在有人提交表单时显示成功消息,我正在使用此代码
$('form').on('submit',function(){
alert('submitted');
});
但由于未知原因,此代码不起作用,这是页面网址 http://timesharesgroup.com/sell/index.html
P.S 我的目标是在用户提交表单时向用户显示成功消息,我认为 javascript 是一种简单的方法,但如果您能想出更好的选择,我将不胜感激 目前表单的工作方式如下:
- 用户提交
- 为他刷新页面
- 我收到一封包含提交数据的电子邮件
**********更新**********************
【问题讨论】:
-
请添加比“它不起作用”更多的细节。你试图做什么来修复或调试它?你检查过控制台吗?页面中是否包含 jQuery.js?是否正确加载?您的代码是否在 DOMReady 之前运行?
alert()是否显示,但表单仍在提交中?在这里与我们合作... -
我在表单下方的 index.html 中添加了代码。请检查更新的问题。
-
如果我没记错 jquery.js 丢失
-
@Danyal
Uncaught ReferenceError: $ is not defined
标签: javascript php jquery html forms