onSubmit JavaScript not working - why?

Hi everyone!

The following Javascript code (in the onSubmit event) is not working, and I don’t know why:

var field = document.forms[0].elements(“DeptPhone”).value;

if(field=“”)

{

alert(“You must enter value to DeptPhone!”);

return false;

}

return true;

Any ideas?

Subject: onSubmit JavaScript not working - why?

hi…

the basic error you are doing is in the if clause “=” in javascript is an assignment operator you should use “==”

eg:

var field = document.forms[0].elements.(“DeptPhone”).value;

if(field == “”)

{

alert(“You must enter value to DeptPhone!”);

}

cheers…

kaushik das

Subject: Re: onSubmit JavaScript not working - why?

WOW! Thanx :wink: