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>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.