gazever Posted January 20, 2010 Share Posted January 20, 2010 Hi Im really a PHP programmer and trying to cobble together some code for a very simple form validation, what i need to do is if a select value is at its default state of "Choose size" I need to make an alert saying choose size before sending the form. In IE it keeps saying this page contains errors "object doesnt support this method or property "but functions ok, however this is stopping me from adding another zooming in javascript for images. Could someone Please amend or let me know what im doing wrong. in the head <script type="text/javascript"> function submitform(){ var sizevar = document.getElementById("size"); if(!madeSelection(sizevar, "Please Choose a Size")){ } } function madeSelection(elem, helperMsg){ if(elem.value == "choose"){ alert(helperMsg); elem.focus(); return false; }else{ document.addtocart.submit(); } } </script> bit of a mismatch of code, dont know javascript and the link to submit the form <a href="javascript: submitform()" class="buy">Add to shopping bag</a> Thanks! Quote Link to comment Share on other sites More sharing options...
gazever Posted January 21, 2010 Author Share Posted January 21, 2010 if anyones interested here final working code, however IE8 doesnt show the alert message, anyone know why? <script type="text/javascript"> function submitform(){ var selectedvalue = document.getElementById("size") ; if(selectedvalue.value == "choose"){ alert("Please choose a size"); } else { document.addtocart.submit(); } } </script> <a href="javascript:submitform()" class="buy">Add to shopping bag</a> 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.