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> Link to comment https://forums.phpfreaks.com/topic/158143-this-is-not-working-see-anything-wrong/ Share on other sites More sharing options...
jackpf Posted May 14, 2009 Share Posted May 14, 2009 onsubmit is a form attribute. Link to comment https://forums.phpfreaks.com/topic/158143-this-is-not-working-see-anything-wrong/#findComment-834198 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()"> Link to comment https://forums.phpfreaks.com/topic/158143-this-is-not-working-see-anything-wrong/#findComment-834200 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> Link to comment https://forums.phpfreaks.com/topic/158143-this-is-not-working-see-anything-wrong/#findComment-834204 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.