Hello all!
I have developed a search form that allows any form element (or mutiplie form elements) to be filled in to conduct the search. However, I want the user to be required to fill out at least ONE form element before they hit Submit.
I have found many scripts that “require” a form element, but I want to build a script that only requires ANY form element (not a specfic one).
I have done fine with typical text boxes, but I am stumped when it comes to a Checkbox or a Drop Down.
First, here is my js code for the form check:
<script language="JavaScript"> <!--
function anyvalidate() {
if ( form.box1.value == ""
&& form.box2.value == ""
&& form.box3.value == ""
&& form.box4.value == ""
&& form.box5.value == ""
&& form.box6.value == "") {
alert( "You need to complete at least 1 field to conduct a search" );
return false;
}
}
//--> </script>
Here is the form:
<form name="form" action="" onSubmit="return anyvalidate()" method="post">
<p>
<input name="box1" type="text">
</p>
<p>
<input name="box2" type="text">
</p>
<p>
<input name="box3" type="text">
</p>
<p>
<input name="box4" type="text">
</p>
<p>
<input name="box5" type="text">
</p>
<p>
<input name="box6" type="text">
</p>
<p>
<input type="checkbox" name="ckbox7" value="1">
</p>
<p>
<select name="drop8">
<option> </option>
<option>one</option>
<option>two</option>
<option>three</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
Could you fine folks tell me how I would go about checking to see if the Checkbox has been filled out or the Drop Down menu selected?
I TRULY would appreciate any help
Take care