Jump to content


Validate Textbox Before Continuing To Paypal Payment Page

  • Please log in to reply
4 replies to this topic

#1 Classico

  • Members
  • PipPip
  • Member
  • 21 posts

Posted 13 December 2012 - 07:13 PM

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!");
	 return false;
	 return true;
			 <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">

Is there an easier way to check this?

#2 Pikachu2000

  • Staff Alumni
  • I hate everything.
  • 11,384 posts
  • LocationFuture Independent Republic of Texas
  • Age:106

Posted 13 December 2012 - 07:26 PM

You aren't really using hidden form fields to hold pricing information being sent to paypal, right?

"Java" is to "Javascript" about the same as "fun" is to "funeral".

Why $_SERVER['PHP_SELF'] is bad. || Why ORDER BY RAND() is bad || Every problem can be solved with rm -rf *

Random Quote: "

Remember, you're unique. Just like everybody else!

#3 mrMarcus

  • Members
  • PipPipPip
  • I'm a beleafer.
  • 1,903 posts
  • LocationCanada

Posted 13 December 2012 - 07:58 PM

You haven't called the checkForm() function anywhere that I can see.  Functions don't just run on their own.

#4 Classico

  • Members
  • PipPip
  • Member
  • 21 posts

Posted 14 December 2012 - 10:13 AM

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

#5 PFMaBiSmAd

  • Staff Alumni
  • Advanced Member
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 15 December 2012 - 02:04 AM

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.)
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users