chet139 Posted February 12, 2008 Share Posted February 12, 2008 Hey all, I have basic searc forms however I need to ensure that at least one field is filled in. This could include the one field has being a dropdown menu. Any help is appreciated as I am at a lost with this. I got some code which does what I need but it ignores the dropdowns - I have tried amending code but have had no success. As you may have gathered I am quite new to this. Here is the code: (but feel free to post something else which maybe simplier that I can use.) <script type="text/javascript"> function validateAdvSearch() //Validation to ensure that a blank form is not submitted. { var f = document.forms[0]; var num = f.elements.length; var j = 0; for (var i=0; i<num; i++) { if (f.elements.type == 'text') { if (f.elements.value) { j = j+1; } } else { continue; } } if (j == 0) { alert('Please Enter at least One Search Criteria'); return false; } } </script> Quote Link to comment Share on other sites More sharing options...
chet139 Posted February 12, 2008 Author Share Posted February 12, 2008 All, I think I may have solved this. Please add comments to my solution. <script type="text/javascript"> function checkFields() { if(user.userId.value != "" || user.userTitle.value != "" || user.userFirstname.value != "" || user.userLastname.value != "" || user.userType.value != "") { alert("Validation OK"); // Success Code goes here return true; } else { alert("Please Provide Minimum of One Search Criteria"); return false; } } </script> 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.