JRS: In article <DJ********************@comcast.com>, dated Thu, 20 Oct
2005 16:16:13, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
web.dev said the following on 10/20/2005 2:28 PM:
And then in your javascript:
function validateForm()
{
var myForm = document.forms["myForm"];
var error = true;
if(myForm.elements["textBox"].value != "")
{
error = false;
}
else
{
error = true;
}
return (err) ? false : true;
Why make it more difficult than it needs be?
return error;
As 'err' is undefined.
The else statement is not needed either. It only sets error to true and
it was true to begin with. Although it may be better reasoning to set
error=false and then return !error
function validateForm() {
return document.forms["myForm"].elements["textBox"].value != "" }
or possibly == "" or > "" or
function validateForm() {
return !!document.forms["myForm"].elements["textBox"].value }
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
The Big-8 newsgroup management is attempting to legitimise its questionable
practices while retaining its elitist hegemony. Read <URL:news:news.groups>.