function checkForm(f) {
if (f.elements['zoom_query'].value == "" || "Search - Movie or Actor") {
f.zoom_query.focus();
return false;
} else {
f.submit();开发者_运维百科
return false;
}
}
this prevents form submission for any string
any idea?
I think it should read:
(f.elements['zoom_query'].value == "" || f.elements['zoom_query'].value == "Search - Movie or Actor")
Otherwise it always evaluates true
If you can use jQuery I'd recommend having a look here: http://docs.jquery.com/Plugins/validation
And this question contains an answer that solves the problem you're having using jQuery Form Validation.
function checkForm(f) {
if (f.zoom_query.value == "" || f.zoom_query.value == "Search - Movie or Actor") {
alert("Please fill in the text field.");
f.zoom_query.focus();
return (false);
}
f.submit();
return (true);
}
精彩评论