我正在寻找有关如何完成此任务的建议。我想在我的网站上实现这个(见例子)。基本上,只是一个带有paypal按钮的表单,在提交之前,它必须经过验证。
我没有看到问题。任何指导都会非常感激。
这是我到目前为止所拥有的!
<form id="unlockform" action=""https://www.paypal.com/cgi-bin/webscr"" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="example@example.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Factory Unlock for iPhone">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="RCUnlocks_BuyNow_Unlock_US">
<!-- Provide a dropdown menu option field. -->
<div id="error_messages"></div>
<label for="model">iPhone Model</label>
<input type="hidden" name="on0" value="Model"> <br />
<select id="model" name="os0">
<option value="Select your Model">-- Select your Model --</option>
<option value="iPhone 2G">iPhone 2G</option>
<option value="iPhone 3G">iPhone 3G</option>
<option value="iPhone 3GS">iPhone 3GS</option>
<option value="iPhone 4">iPhone 4</option>
<option value="iPhone 4S">iPhone 4S</option>
<option value="iPhone 5">iPhone 5</option>
</select> <br />
<!-- Provide a dropdown menu option field with prices. -->
<label for="services">Unlock Service</label>
<input type="hidden" name="on1" value="Service"> <br />
<select id="service" name="os1" class="required">
<option value="Sevice">-- Select your Service --</option>
<option value="Instant-90min">AT&T Instant-90min max - $6.25</option>
<option value="1-6Hrs">AT&T 1-6 hours - $5.00</option>
<option value="1-24Hrs">AT&T 1-24 hours - $3.50</option>
</select> <br />
<!-- Specify the price that PayPal uses for each option. -->
<input type="hidden" name="option_index" value="1">
<input type="hidden" name="option_select0" value="Instant-90min">
<input type="hidden" name="option_amount0" value="6.25">
<input type="hidden" name="option_select1" value="1-6Hrs">
<input type="hidden" name="option_amount1" value="5.00">
<input type="hidden" name="option_select2" value="1-24Hrs">
<input type="hidden" name="option_amount2" value="3.50">
<label>IMEI #</label>
<input type="hidden" name="on2" value="IMEI#">
<input type="text" name="os2" id="imeino" maxlength="15" required="required" >
<br>
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" id="submit" src="paypal.gif"alt="PayPal - The safer, easier way to pay online" >
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
这是我的剧本!
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="/js/jquery.validate.min.js"></script>
<script>
$(document).ready(function (){
jQuery.validator.setDefaults({
errorPlacement: function(error, element){
error.appendTo(element.parent().find('div.error_messages'));
}
});
$('#unlockform').validate({
rules:{
model:{
required:true
},
services:{
required: true
},
imeino:{
required: true,
number: true
};
},
messages:{
model:{
required: "Please select one option.<br>"
},
services:{
required: "Please select one option.<br>"
},
imeino:{
required: "You must enter your phone's IMEI#.",
number:"IMEI # must be numbers only!!!"
}
},
errorContainer: "#error_messages",
errorLabelContainer: "#error_messages"
});
submitHandler:function(){
alert('Form validation was a success!')
}
});
</script>
非常感谢你们!
这是一个小提琴... form
我的问题是表格没有得到验证...... !!