javascript - Simple form validation -
post #1
how can validate simple form (checking empty field strings)?
<p>please select gift certificate amount below. please enter name , gift certificate recipient's name. once click 'buy now' sent our paypal site complete purchase.</p> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="sdsafsdafsadfdsafsdafsadfsadfsadfasdfsadfsdaf"> <table width="100%"> <tr> <td width="130"><input type="hidden" name="on0" value="amount"><p>amount</p></td> <td><select name="os0"> <option value="option 1">$20.00</option> <option value="option 2">$50.00</option> <option value="option 3">$100.00</option> </select></td> </tr> <tr> <td><input type="hidden" name="on1" value="to:"><p>to (full name):</p></td> <td><input type="text" name="os1" maxlength="60" size="30"></td> </tr> <tr> <td><input type="hidden" name="on2" value="from:"><p>from (full name):</p></td> <td><input type="text" name="os2" maxlength="60" size="30"></td> </tr> </table> <table width="100%" style="margin-top: 10px;"> <tr> <td><input type="hidden" name="currency_code" value="cad"> <p><input type="image" src="button.jpg" border="0" name="submit" alt="paypal - safer, easier way pay online!"></p> <img alt="" border="0" src="https://www.paypal.com/en_us/i/scr/pixel.gif" width="1" height="1"></td> <td align="right"><img src="../paypal_logo.jpg" alt="paypal" /></td> </tr> </table> </form>
post #2
function validate_form() { valid = true;
if ( document.giftform.os1.value == "" ) { alert ( "please fill in 'your name' box." ); valid = false; } return valid; }
-=-=-=-= form
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" method="giftform" onsubmit="validate_form( )"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="sdsafsdafsadfdsafsdafsadfsadfsadfasdfsadfsdaf"> <table width="100%"> <tr> <td width="130"><input type="hidden" name="on0" value="amount"><p>amount</p></td> <td><select name="os0"> <option value="option 1">$20.00</option> <option value="option 2">$50.00</option> <option value="option 3">$100.00</option> </select></td> </tr> <tr> <td><input type="hidden" name="on1" value="to:"><p>to (full name):</p></td> <td><input type="text" name="os1" maxlength="60" size="30"></td> </tr> <tr> <td><input type="hidden" name="on2" value="from:"><p>from (full name):</p></td> <td><input type="text" name="os2" maxlength="60" size="30"></td> </tr> </table> <table width="100%" style="margin-top: 10px;"> <tr> <td><input type="hidden" name="currency_code" value="cad"> <p><input type="image" src="button.jpg" border="0" name="submit" alt="paypal - safer, easier way pay online!"></p> <img alt="" border="0" src="https://www.paypal.com/en_us/i/scr/pixel.gif" width="1" height="1"></td> <td align="right"><img src="../paypal_logo.jpg" alt="paypal" /></td> </tr> </table> </form>
is jquery option? there's nice validation tool http://docs.jquery.com/plugins/validation
Comments
Post a Comment