nertskull Posted July 29, 2010 Share Posted July 29, 2010 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 https://forums.phpfreaks.com/topic/209237-alternate-submit-button-doesnt-process-java/ Share on other sites More sharing options...
Pikachu2000 Posted July 29, 2010 Share Posted July 29, 2010 So what is the php-related problem with this script? Nevermind. Moved to appropriate forum by mod. Link to comment https://forums.phpfreaks.com/topic/209237-alternate-submit-button-doesnt-process-java/#findComment-1092614 Share on other sites More sharing options...
nertskull Posted July 29, 2010 Author Share Posted July 29, 2010 thanks, sorry, i need to pay more attention to which link i clicked on the forums, thanks for moving it Link to comment https://forums.phpfreaks.com/topic/209237-alternate-submit-button-doesnt-process-java/#findComment-1092624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.