Jump to content

Validate Textbox Before Continuing To Paypal Payment Page


Recommended Posts

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?

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. :)

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.)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.