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

Reply via email to