Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make paypal button fields 'Required'?
    primarykey
    data
    text
    <p>i have created a pay now button using paypal button generator.</p> <p>The button has 2 fields, and then you press pay now.</p> <p>However, if you leave these fields empty, you can still pay</p> <p>I want to make these fields "required", if a user didn't fill these fields, he should not be able to pay. How?</p> <p>The button is not hosted on paypal, but the button protection is <strong>ON</strong>. I want the button to be encrypted.</p> <p><strong>EDIT</strong></p> <p>i tried javascript form validation, didn't work, any help?</p> <p>here's the script</p> <pre><code>&lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt; &lt;input type="hidden" name="cmd" value="_s-xclick"&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="on0" value="first form"&gt;form 1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="text" name="os0" maxlength="200"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="on1" value="2nd form"&gt;2nd form&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="text" name="os1" maxlength="200"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;input type="hidden" name="encrypted" value=" encryption here "&gt; &lt;input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt; &lt;img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"&gt; &lt;/form&gt; </code></pre> <p>any help making these field required? I'll give you 3 up votes because i have 3 stackoverflow accounts and an accepted answer - that's the least i can do :)</p> <p><strong>PS</strong></p> <p>i couldn't make the form validation work, so i tried to hide the submit button unless the forms are filled, so far, that didn't work as well.</p> <p><strong>UPDATE - @Last Rose Studios</strong></p> <p>I tried many validation ways, finally i used my friend's contact form validation lol</p> <p><strong>validation.js</strong></p> <pre><code>function has_id(id){try{var tmp=document.getElementById(id).value;}catch(e){return false;} return true;} function has_name(nm){try{var tmp=cfrm.nm.type;}catch(e){return false;} return true;} function $$(id){if(!has_id(id)&amp;&amp;!has_name(id)){alert("Field "+id+" does not exist!\n Form validation configuration error.");return false;} if(has_id(id)){return document.getElementById(id).value;}else{return;}} function $val(id){return document.getElementById(id);} function trim(id){$val(id).value=$val(id).value.replace(/^\s+/,'').replace(/\s+$/,'');} var required={field:[],add:function(name,type,mess){this.field[this.field.length]=[name,type,mess];},out:function(){return this.field;},clear:function(){this.field=[];}};var validate={check:function(cform){var error_message='Please fix the following errors:\n\n';var mess_part='';var to_focus='';var tmp=true;for(var i=0;i&lt;required.field.length;i++){if(this.checkit(required.field[i][0],required.field[i][1],cform)){}else{error_message=error_message+required.field[i][2]+' must be supplied\n';if(has_id(required.field[i][0])&amp;&amp;to_focus.length===0){to_focus=required.field[i][0];} tmp=false;}} if(!tmp){alert(error_message);} if(to_focus.length&gt;0){document.getElementById(to_focus).focus();} return tmp;},checkit:function(cvalue,ctype,cform){if(ctype=="NOT_EMPTY"){if(this.trim($$(cvalue)).length&lt;1){return false;}else{return true;}}else if(ctype=="EMAIL"){exp=/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;if($$(cvalue).match(exp)==null){return false;}else{return true;}}},trim:function(s){if(s.length&gt;0){return s.replace(/^\s+/,'').replace(/\s+$/,'');}else{return s;}}}; </code></pre> <p><strong>paypal.html</strong></p> <pre><code>&lt;script src="validation.js"&gt;&lt;/script&gt; &lt;script&gt; required.add('os0','NOT_EMPTY','1st form'); required.add('os1','NOT_EMPTY','2nd form') &lt;/script&gt; &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="return validate.check(this)"&gt; &lt;input type="hidden" name="cmd" value="_s-xclick"&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="on0" value="1st form"&gt;1st form&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="text" name="os0" maxlength="200" id="os0" class="required"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="on1" value="2nd form"&gt;2nd form&lt;span class="required_star"&gt; * &lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="text" id="os1" name="os1" maxlength="200" class="required"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;input type="hidden" name="encrypted" value=" encryption here "&gt; &lt;input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt; &lt;img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"&gt; &lt;/form&gt; </code></pre> <p>I have used JavaScript, and then i read your answer, but i'm not gonna change because it works now</p> <p>i still have 2 small questions</p> <p>1- is it possible to remove the description box from paypal page see this<img src="https://i.stack.imgur.com/MQZhE.png" alt="enter image description here"></p> <p>2- paypal is not redirecting to the thank you page after the payment is done, i created many button, it's just not redirecting (i don't have a cancel page)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload