我正在使用自定义的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是一种简单的方法,但如果你能提出更好的选择,我将非常感激 目前表单的工作方式如下:
********** UPDATE *****************
答案 0 :(得分:1)
您使用的是jQuery而不是JavaScript。为此,您需要在头部包含jQuery.js
。在<head>
标记中添加以下内容:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
如果您想使用JavaScript,可以进行以下更改:
原文:<input id="submit" type="submit" value="" />
修改:<input id="submit" type="submit" onclick="alert("success");" value="" />