zang8027 Posted May 14, 2009 Share Posted May 14, 2009 my onsubmit is not firing <form name="paypalForm" action="paypal.com" method="post"> <input type="text" name="quantity" value="type your quantity" onsubmit="validateIt()" onfocus="clearVal" /> <script> function validateIt() { var quan= document.paypalForm.quantity.value; if(quan>=0) { if(quan<=1000) { alert("The price is 19 cents"); } } else if(quan>=1001) { if(quan<=5000) { alert("The price is 18 cents"); } } else if(quan>=5001) { if(quan<=10000) { alert("The price is 17 cents"); } } } </script> Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 14, 2009 Share Posted May 14, 2009 onsubmit is a form attribute. Quote Link to comment Share on other sites More sharing options...
zang8027 Posted May 14, 2009 Author Share Posted May 14, 2009 ok i added it to the <form> but i am still not getting an alert.. should i get it when i click the button? <form name="paypalForm" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onsubmit="validateIt()"> Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 14, 2009 Share Posted May 14, 2009 This works for me <script> function validateIt() { var quan= document.paypalForm.quantity.value; if(quan>=0) { if(quan<=1000) { alert("The price is 19 cents"); } } else if(quan>=1001) { if(quan<=5000) { alert("The price is 18 cents"); } } else if(quan>=5001) { if(quan<=10000) { alert("The price is 17 cents"); } } } </script> <form name="paypalForm" action="paypal.com" method="post" onsubmit="validateIt();"> <input type="text" name="quantity" value="type your quantity" /> </form> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.