I have a form, that needs some JS help.
I need a script that does two things:
1.) makes sure that at least one of 'keyword1' OR 'keyword_phrase'
are not blank
2.) It somebody chooses a time period from the drop-down, that the
radio button for 'timeperiod' is selected automatically.
Can anybody give me some guidance? I've got the first part of the
script done... It checked for keyword1 being blank. I tried just adding
another && notEmpty(form.keyword_phrase) to the script besides the
first if... And that didn't help.
THANK YOU!!
*** *** ***
THE SCRIPT SO FAR:
*** *** ***
<script type="text/_javascript_">
function formValidation(form){
if(notEmpty(form.keyword1))
{
{
return true;
}
}
return false;
}
function notEmpty(elem){
var str = elem.value;
if(str.length == 0){
alert("You must enter a keyword or phrase to continue.");
return false;
} else {
return true;
}
}
</script>
*** *** ***
THE FORM:
*** *** ***
<form action="" method="post" name="advanced_form"
formValidation(this)">
<b>Search:</b>
<br /><br />
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<td>For the <b>keywords</b>:</td>
<td>
<input type="text" name="keyword1" size="10" />
<select name="operator">
<option value="AND">AND
<option value="NOT">NOT
<option value="OR">OR
</select>
<input type="text" name="keyword2" size="10" />
<select name="operator2">
<option value="AND">AND
<option value="NOT">NOT
<option value="OR">OR
</select>
<input type="text" name="keyword3" size="10" />
</td>
</tr>
<tr>
<td>For the <b>exact phrase</b>:</td>
<td><input type="text" name="keyword_phrase" size="30" /></td>
</tr>
<tr>
<td><br />For <b>document type</b>:</td>
<td>
<br />
<select name="collection">
<option value="all_documents" selected>All
Documents</option>
<option value="annual_report">Annual Report</option>
<option value="book">Books</option>
</select>
</td>
</tr>
<tr>
<td valign="top"><br />From pages <b>created</b>:</td>
<td valign="top">
<br />
<input type="radio" name="timeperiod" value="anytime" checked
/>anytime
<br /><input type="radio" name="timeperiod" value="range" />
<select name="created">
<option value="OneWeek">one week
<option value="TwoWeeks">two weeks
<option value="OneMonth">one month
<option value="ThreeMonths">three months
<option value="OneYear">one year
</select>
ago
<br /><input type="radio" name="timeperiod" value="between"
/>between
<input type="text" name="startdate" size="10" /> <a
href="" 'startdate')"><img
src="" width="16" height="16" border="0" alt="Click here
to choose a date."></a>
and <input type="text" name="enddate" size="10" /> <a
href="" 'enddate')"><img
src="" width="16" height="16" border="0" alt="Click here
to choose a date."></a>
</td>
</tr>
<tr>
<td><br /> </td>
<td>
<br />
<input type="hidden" name="action" value="advanced">
<input type="hidden" name="FindMe" value="FindMe">
<input type="submit" name="submit" value="search">
</td>
</tr>
</table>
</form>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

