Classico Posted December 13, 2012 Share Posted December 13, 2012 I have a small javascript function which is meant to check if a user has entered anything in the given textbox. <script type="text/javascript"> function checkForm(form) { if(form.on0.value == '') { alert("Error: No amount was entered!"); form.on0.focus(); return false; } return true; } </script> <form action="https://www.paypal.com/cgi-bin/webscr" method="POST"> <input type="text" name="on0" value="" placeholder="Username"> That doesn't seem to work when I press my PayPal button. <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="donate@dawncraftmc.com"> <input type="hidden" name="item_name" value="VIP"> <input type="hidden" name="item_number" value="1"> <input type="hidden" name="amount" value="2.50"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="lc" value="GB"> <input type="hidden" name="bn" value="PP-BuyNowBF"> <input type="hidden" name="return" value="http://www.dawncraftmc.com/index.html"> <input type="hidden" name="cancel_return" value="http://www.dawncraftmc.com/index.html"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="notify_url" value="http://vip.dawncraftmc.com/ipn.php" /> <input type="hidden" name="custom" value="<?php echo $on0; ?>"> <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online."> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form> Is there an easier way to check this? Quote Link to comment https://forums.phpfreaks.com/topic/271972-validate-textbox-before-continuing-to-paypal-payment-page/ Share on other sites More sharing options...
Pikachu2000 Posted December 13, 2012 Share Posted December 13, 2012 You aren't really using hidden form fields to hold pricing information being sent to paypal, right? Quote Link to comment https://forums.phpfreaks.com/topic/271972-validate-textbox-before-continuing-to-paypal-payment-page/#findComment-1399239 Share on other sites More sharing options...
mrMarcus Posted December 13, 2012 Share Posted December 13, 2012 You haven't called the checkForm() function anywhere that I can see. Functions don't just run on their own. Quote Link to comment https://forums.phpfreaks.com/topic/271972-validate-textbox-before-continuing-to-paypal-payment-page/#findComment-1399242 Share on other sites More sharing options...
Classico Posted December 14, 2012 Author Share Posted December 14, 2012 You aren't really using hidden form fields to hold pricing information being sent to paypal, right? It checks the price in my IPN script, but I also have the price in the button code too. Is there another way of holding the pricing information? You haven't called the checkForm() function anywhere that I can see. Functions don't just run on their own. Oops, my bad! I forgot to add 'onsubmit="return checkForm(this);"' to my form code. Thanks for that. Quote Link to comment https://forums.phpfreaks.com/topic/271972-validate-textbox-before-continuing-to-paypal-payment-page/#findComment-1399333 Share on other sites More sharing options...
PFMaBiSmAd Posted December 15, 2012 Share Posted December 15, 2012 Setting the price in a button or hidden form field is only 'safe' for donations, where the visitor is the one who set the amount he is willing to donate. For everything else, you need to set the amounts in your paypal account for each item (I don't recall exactly what this is called on the paypal side of things.) Quote Link to comment https://forums.phpfreaks.com/topic/271972-validate-textbox-before-continuing-to-paypal-payment-page/#findComment-1399481 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.