1

我正在尝试获取一个简单的条款和条件复选框以在允许用户单击贝宝按钮之前进行验证。我目前有这个代码:

<form 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="my email"> 

    <!-- 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="15-minutes"> 
    <input type="hidden" name="amount" value="15.00">  
    <input type="hidden" name="currency_code" value="USD"> 

    <!-- Display the payment button. --> 
    <input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"alt="stuff"> 
    <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > 
</form>  

任何帮助或指导都会非常有帮助。

我们其他人的节日,

汤姆

4

1 回答 1

1

像这样的小 jQuery 应该可以解决问题:http: //jsfiddle.net/mVK4r/

我添加了一个条款和条件复选框,然后测试它是否被选中。如果是,则该按钮的行为正常。如果不是,则会出现提示用户接受条款的警报,并且该按钮将不起作用。

希望这有帮助,祝你好运!

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 

<!-- Terms and Conditions check box -->
<p><input type="checkbox" id="terms"> Yes, I accept the terms and conditions</p>
<p>&nbsp;</p>

<!-- Identify your business so that you can collect the payments. --> 
<input type="hidden" name="business" value="my email"> 

<!-- 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="15-minutes"> 
<input type="hidden" name="amount" value="15.00">  
<input type="hidden" name="currency_code" value="USD"> 

<!-- Display the payment button. --> 
<input type="image" id="button" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="stuff"> 
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > 
</form>  ​

<script type="text/javascript">
$(function(){
    $('#button').click(function(e){
        if ($('#terms').prop('checked') == false) {
            alert('Please accept the terms and conditions');
            e.preventDefault();  
    }
    else {
       // Allow the button the do its thing
        }
    });
});​
</script>
于 2012-11-26T03:07:25.207 回答