K
kdc
Hello,
I would appreciate any help I can get from anyone who has experience
using javascript. I have an html form containing a number of functions
controlling the submission of data to our database. I now want to
require users to fill in three specific fields before they can submit
the form. I found a function and modified it with my form name
(mainform), and field names(sub 1,2 and 3)
In the head of the document, I added this function to the existing ones
that work successfully:
function required()
{
if (document.mainform.sub1.value==" ")
{
alert("Please Enter Name!");
document.mainform.sub1.focus()
return false;}
return true;
if (document.mainform.sub2.value==" ")
{
alert("Please Enter Position");
document.mainform.sub2.focus()
return false;}
return true;
if (document.mainform.sub3.value==" ")
{
alert("Please Enter Email Address");
document.mainform.sub3.focus()
return false;}
return true;
}
In the body I have
form name ="=mainform"
The other functions that work prevent submission under certain
conditions, but my new function is just ignored. Does anyone have any
suggestions?
Thanks, kdc
I would appreciate any help I can get from anyone who has experience
using javascript. I have an html form containing a number of functions
controlling the submission of data to our database. I now want to
require users to fill in three specific fields before they can submit
the form. I found a function and modified it with my form name
(mainform), and field names(sub 1,2 and 3)
In the head of the document, I added this function to the existing ones
that work successfully:
function required()
{
if (document.mainform.sub1.value==" ")
{
alert("Please Enter Name!");
document.mainform.sub1.focus()
return false;}
return true;
if (document.mainform.sub2.value==" ")
{
alert("Please Enter Position");
document.mainform.sub2.focus()
return false;}
return true;
if (document.mainform.sub3.value==" ")
{
alert("Please Enter Email Address");
document.mainform.sub3.focus()
return false;}
return true;
}
In the body I have
form name ="=mainform"
The other functions that work prevent submission under certain
conditions, but my new function is just ignored. Does anyone have any
suggestions?
Thanks, kdc