PDA

View Full Version : validation not workin in IE


Subjective Effe
07-12-2004, 02:36 PM
What is wrong with this code? IE returns false even if search_category.value has a value. It is coming from a select in a form.

function check_submit(searchform){
if (!searchform.search_isbn.value
&&!searchform.search_title.value
&&!searchform.search_authors.value
&&!searchform.search_edition.value
&&!searchform.search_category.value
){
alert("You have not entered any search terms.");
return false;
}
else{
return true;
}
}

pyrexyn
07-12-2004, 02:39 PM
possibly spacing after the "&&" and before the "!"? Maybe it's a JavaScript version thing, where you can't just make a not statement to verify if a variable contains something. Try comparing each variable to empty strings.

Subjective Effe
07-12-2004, 07:54 PM
But it works for everything but the last one - only &&!searchform.search_category.value does not work. And only IE.

IKLOP
07-12-2004, 08:10 PM
have you tried alert()'ing searchform.search_category.value and making sure there is value in it?

Also, you could try comparing search_category.value with an empty string:
... && searchform.search_category.value==""

Jon Hanlon
07-12-2004, 08:56 PM
Please post the HTML code for the form.

Subjective Effe
07-12-2004, 09:59 PM
Fixed. I used alert to examine the values (thanks IKLOP). Nothing.

So I looked at the code.

I had missed out value="" in the option tag. FF and Opera were too forgiving. It works fine now.