Jump to content

Alternate submit button doesn't process java


nertskull

Recommended Posts

So I have a form that I want to validate an email address on.

 

BUT, I was using a different type of submit button (with a picture) and It doesn't work.

 

This is my submit button

<div class="buttonwrapper">
<a class="ovalbutton" href="javascript:void(null);" onClick="document.InputData.submit();"><span>Register!</span></a>
</div>

 

which will submit my registration form withOUT the validation stuff.

 

BUT, when I try to add in something to validate my emails, my form submits without validating.

 

In other words, if I put in a regular submit button (type="submit") then it validates emails and won't let something odd be submitted. 

 

Is there a way to use a non traditional form submit button, but still have it validate my emails???

 

 

for the sake of completeness, here is the validation code I'm using, in case its a problem there (i doubt it since it works with a normal submit)

<script language = "Javascript">

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid E-mail ID")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail ID")
	    return false
	 }

		 return true					
}

function ValidateForm(){
var emailID=document.InputData.email

if ((emailID.value==null)||(emailID.value=="")){
	alert("Please Enter your Email ID")
	emailID.focus()
	return false
}
if (echeck(emailID.value)==false){
	emailID.value=""
	emailID.focus()
	return false
}
return true
}
</script>

 

and then the form is basically

 <form name="InputData" action="action_go/register_go.php" method="post" onSubmit="return ValidateForm()">
<tr><th class="main">Email: </th><td><input type="text" name="email" maxlength="50" /></td></tr>
<tr><td><div class="buttonwrapper">
<a class="ovalbutton" href="javascript:void(null);" onClick="document.InputData.submit();"><span>Register!</span></a>
</div></td></tr>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.