Thanks, I will give it a try...
Hi,
The "forms[0]" part of "document.forms[0].email.value.length"
refers to the first form on the page. "forms[1]" would be the
second form on the page. That's why it's bombing. You can
either use forms[1] in your example, or you can name your
form.
For instance:
<FORM name="Email_Form" METHOD="POST"
ACTION="email.taf?function=email onSubmit="return checkData()">
Then your form references would look like:
document.Email_Form.email.value.length
Stefan
At 08:46 AM 4/8/2005, you wrote:
Not really a js guy, but I was wondering if someone could help me
with a small problem I am having. A simple problem and probably
very easy for someone who knows...
I am running an email validation script which works very well, but
it only works when I have just one <form> element on the page. In
other words, if I have something like this...
<FORM METHOD="POST" ACTION="basket.taf?function=insert>
whatever
<input type=submit value='Buy'></Form>
AND
<FORM METHOD="POST" ACTION="email.taf?function=email
onSubmit="return checkData()">
whatever
<input type=submit value='Email'></Form>
it bombs.
A single <FORM METHOD="POST" ACTION="email.taf?function=email
onSubmit="return checkData()"> and it works great, Any more <forms>
on the page and it bombs. I know I have to name the form somehow,
but my brain can't get it.
Any help would be appreciated
The following is the snip I am using...
<script language="JavaScript">
<!--
function checkData (){
if (document.forms[0].email.value.length ==0){
alert("Please enter valid email address.")
return false}
if (document.forms[0].email.value.length >0){
i=document.forms[0].email.value.indexOf("@")
j=document.forms[0].email.value.indexOf(".",i)
k=document.forms[0].email.value.indexOf(",")
kk=document.forms[0].email.value.indexOf(" ")
jj=document.forms[0].email.value.lastIndexOf(".")+1
len=document.forms[0].email.value.length
if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) &&
(len-jj >=2) && (len-jj<=3)) {
}
else {
alert("Please enter valid email address.\n" +
document.forms[0].email.value + " is invalid.")
return false}}
}
//-->
</script>
<FORM METHOD="POST" ACTION="email.taf?_function=email"
onSubmit="return checkData()">
<INPUT NAME="email" TYPE=TEXT SIZE=32 MAXLENGTH=32>
<INPUT TYPE=SUBMIT VALUE="Email Us!"></form>
Thanks in advance!
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
=====================================================
Database WebWorks: Dynamic web sites through database integration
http://www.DatabaseWebWorks.com
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf