php - Validate a form before sending it to paypal using jquery -
i looking advise in how complete task. trying implement (see example) in website. basically, form buy button paypal , before submitted, has validated.
i not see problem. guidance appreciated.
this have far!
<form id="unlockform" action=""https://www.paypal.com/cgi-bin/webscr"" method="post"> <!-- identify business can collect payments. --> <input type="hidden" name="business" value="example@example.com"> <!-- specify buy button. --> <input type="hidden" name="cmd" value="_xclick"> <!-- specify details item buyers purchase. --> <input type="hidden" name="item_name" value="factory unlock iphone"> <input type="hidden" name="currency_code" value="usd"> <input type="hidden" name="bn" value="rcunlocks_buynow_unlock_us"> <!-- provide dropdown menu option field. --> <div id="error_messages"></div> <label for="model">iphone model</label> <input type="hidden" name="on0" value="model"> <br /> <select id="model" name="os0"> <option value="select model">-- select model --</option> <option value="iphone 2g">iphone 2g</option> <option value="iphone 3g">iphone 3g</option> <option value="iphone 3gs">iphone 3gs</option> <option value="iphone 4">iphone 4</option> <option value="iphone 4s">iphone 4s</option> <option value="iphone 5">iphone 5</option> </select> <br /> <!-- provide dropdown menu option field prices. --> <label for="services">unlock service</label> <input type="hidden" name="on1" value="service"> <br /> <select id="service" name="os1" class="required"> <option value="sevice">-- select service --</option> <option value="instant-90min">at&t instant-90min max - $6.25</option> <option value="1-6hrs">at&t 1-6 hours - $5.00</option> <option value="1-24hrs">at&t 1-24 hours - $3.50</option> </select> <br /> <!-- specify price paypal uses each option. --> <input type="hidden" name="option_index" value="1"> <input type="hidden" name="option_select0" value="instant-90min"> <input type="hidden" name="option_amount0" value="6.25"> <input type="hidden" name="option_select1" value="1-6hrs"> <input type="hidden" name="option_amount1" value="5.00"> <input type="hidden" name="option_select2" value="1-24hrs"> <input type="hidden" name="option_amount2" value="3.50"> <label>imei #</label> <input type="hidden" name="on2" value="imei#"> <input type="text" name="os2" id="imeino" maxlength="15" required="required" > <br> <!-- display payment button. --> <input type="image" name="submit" border="0" id="submit" src="paypal.gif"alt="paypal - safer, easier way pay online" > <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_us/i/scr/pixel.gif" > </form>
here script!
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="/js/jquery.validate.min.js"></script> <script> $(document).ready(function (){ jquery.validator.setdefaults({ errorplacement: function(error, element){ error.appendto(element.parent().find('div.error_messages')); } }); $('#unlockform').validate({ rules:{ model:{ required:true }, services:{ required: true }, imeino:{ required: true, number: true }; }, messages:{ model:{ required: "please select 1 option.<br>" }, services:{ required: "please select 1 option.<br>" }, imeino:{ required: "you must enter phone's imei#.", number:"imei # must numbers only!!!" } }, errorcontainer: "#error_messages", errorlabelcontainer: "#error_messages" }); submithandler:function(){ alert('form validation success!') } }); </script>
thank much!
here fiddle...form
my problem form not validated...!!
Comments
Post a Comment