I have an old page created in clasic asp, contain a form, I am trying to submit the form using JavaScript function after checking the values available in the form.
HTML:
<form method="POST" action="vendorCheckDates.asp" name="Searchform" id="submit_Form">
Select Type of Search: </b>
<select size="1" name="Query" class="button">
<option selected name="vNAME" value="vNAME"> Name</option>
<option name="vNUM" value="vNUM"> Number</option>
<option name="vEM" value="vEM">Email </option>
<option name="vFAX" value="vFAX">Fax </option>
</select>
<b>:</b>
<input type="text" name="hsearch" id="hsearch">
<fieldset class="fieldset">
<legend><strong>Type</strong></legend>
<input type="radio" value="gov" name="tType" >Gov
<input type="radio" value="gfos" name="tType">GFOS
</fieldset>
<input type="button" value="Search" name="hfind" Onclick="SubmitForm()">
</form>
The function
function SubmitForm() {
var hsearch = document.all.submit_Form.hsearch.value;
var tType = document.getElementById('tType').value;
if ((hsearch = ! '') && (hsearch = ! null)) {
if ((tType = ! '') && (tType = ! null)) {
document.all.submit_Form.submit();
} else { alert("please select search type");}
} else { alert("please write search criteria"); }
}
When I run the form the field hsearch is empty, but when I click submit the value will be true, its strange since I still didnt write anything in the input field hsearch, thats why the sels part in JavaScript function will not work