Click to See Complete Forum and Search --> : HTML & JavaScript Help


goddess_spanky
August 15th, 2001, 11:32 AM
Does any know of a good forum for advanced HMTL & JavaScript help? Maybe someone here could help?

I have a submit button that calls an ASP script, but before the script is executed, I have a javascript that checks the search form for value(s). If there is no data in the search form, I have an alert come up and then I have this: "document.frmSearch.cancelEvent = TRUE"
For some reason, the submit event is not cancelled. I get the alert, but the ASP script is still executed?
Yesterday it worked fine and now it is not working today! Any ideas?

Here is the javascript:
<SCRIPT LANGUAGE="JAVASCRIPT">

function checkForm() {
if (document.frmSearch.acctno.value=='' &&
document.frmSearch.login.value=='' &&
document.frmSearch.interval.value=='' &&
document.frmSearch.site.value=='' &&
document.frmSearch.fname.value=='' &&
document.frmSearch.lname.value=='') {
alert('Please complete at least 1 field in the search form');
document.frmSearch.cancelEvent = true;
}
else {
//'document.frmSearch.submit();
}
}

</SCRIPT>


~goddess
goddess_spanky@hotmail.com

vivekkhandelwal
August 24th, 2001, 12:35 AM
The condition you are using as shown by the script posted by you on this site uses a single quote (").

As a result the script checks that if the value entered =="
e.g. fname is left blank.
The script checks if(fname==") then cancel else submit.

In this case the if condition is never true & it always moves control to else condition i.e "submit"