sinernational Posted August 10, 2009 Share Posted August 10, 2009 I need a drop down button to be a required field. I am using formtomail but cannot seem to work out how to do this. Hope someone can help. I have attatched 2 files showing what I need to achieve. Thanks [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/169659-submit-form-drop-down-menu-required-field-need-help/ Share on other sites More sharing options...
kickstart Posted August 10, 2009 Share Posted August 10, 2009 Hi You are attempting to use Javascript to check (so probably should be in the Javascript forum). While it can be useful you need to check in php as well. Probably best to check the selectedIndex of the select drop down. All the best Keith Link to comment https://forums.phpfreaks.com/topic/169659-submit-form-drop-down-menu-required-field-need-help/#findComment-895041 Share on other sites More sharing options...
sford999 Posted August 10, 2009 Share Posted August 10, 2009 You could use somethign like this: <form action="page.php" method="post" enctype="multipart/form-data" name="form_id" id="form_id"> <script language='javascript' type='text/javascript'> form_id = function() { if(document.getElementById('jurisdiction').value == '') { alert('Enter your text here.'); document.getElementById('jurisdiction').focus(); document.getElementById('jurisdiction').select(); return false; } else { return true; } } document.getElementById('form_id').onsubmit = form_id; </script> // Form continues here changing "form_id" for your form name and the alert to whatever you want it to be Link to comment https://forums.phpfreaks.com/topic/169659-submit-form-drop-down-menu-required-field-need-help/#findComment-895182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.