2 Replies - 724 Views - Last Post: 11 June 2012 - 12:39 PM

#1 elbee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-September 10

The generated captcha prevents email validation in my form.

Posted 11 June 2012 - 12:20 PM

Without the captcha code, the email validation works great. With the captcha code,it sends the form without an email address. I'd appreciate any help, Elbee


<head>
<script language = "Javascript">
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

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 Email ID")
		   return false
		}

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

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

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

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

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

 		 return true					
	}

function ValidateForm(){
	var emailID=document.WebsiteQuestion.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>
</head>


<body>

	<div id="websitequestion">
				<form action="websiteformhandler-test.asp" method="post" name="WebsiteQuestion" id="WebsiteQuestion" onsubmit="return ValidateForm()">
				<input type="text" name="Email">

				
					<h1><span>Ask a Question About This Website</span></h1>
					
					<p>Please use this form to submit questions or comments about this website.  Complete the form below then click &quot;Submit.&quot; </p>
					
					<label>Would you like a reply?</label>
					<input type="radio" name="Reply" value="Yes" checked="checked" />
					Yes
					<input type="radio" name="Reply" value="No" />
					No
					
					<p>&nbsp;</p>
					
					<div class="webform">
					
					<p class="break"></p>
					
						<label>Name:</label>				
						<div class="left"><input type="text" class="blue_form_box" name="SubmittedBy" maxlength="75" size="50" />
						</div>
						
					<p style="clear:both"></p>
						
						<label>Library Card:</label>
						<div class="left"><input type="text" class="blue_form_box" name="LibCd" maxlength="75" size="50" />
						</div>
						
					<p style="clear:both"></p>
						
						<label>Street Address:</label>
						<div class="left"><input type="text" class="blue_form_box"name="Address" maxlength="75" size="50" />
						</div>
						
					<p style="clear:both"></p>
						
						<label>City/State:</label>
						<div class="left"><input type="text" class="blue_form_box" name="city" maxlength="50" size="25" />
						</div>
						
					<p style="clear:both"></p>
						
						<label>Zip Code:</label>
						<div class="left"><input type="text" class="blue_form_box" name="zip" maxlength="10" size="11" />
						</div>
						
					<p style="clear:both"></p>
						
						<label>Email Address:</label>
						<div class="left"><input type="text" class="blue_form_box" name="Email" maxlength="75" size="50" /><br />
                        <span class="red">*Required</span>
						</div>
						
					<p style="clear:both"></p>
						
						<label>Question:</label>
						<div class="left"><textarea class="blue_form_box" name="SuggestionText" rows="3" cols="50"></textarea></div>
						
					<p style="clear:both"></p>
                    
                    
					</div>
                    
                    
              <div align="center">
<script language="javascript" src="http://www.captcha.cc/cap.js?cap_k=tocsoLPahVjmEHJZWtenaJEDoJXfrQaa" type="text/javascript"></script>
<input type="hidden" name="cap_h" id="cap_h" value="">
<img border="1" id="cap_i" src="http://www.captcha.cc/img.cgi?cap_k=tocsoLPahVjmEHJZWtenaJEDoJXfrQaa" align="middle"><img align="middle" style="margin-left: 4px;" id=cap_r onload="return cap_showReload(event);" src="http://www.captcha.cc/blank.png"><br>
<input id="cap_t" name="cap_t" type="text" value="" style="margin-top:4px;">
<input type="submit" value="Submit Form" onclick="return cap_valid(event);">						
</div>

</body>


Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: The generated captcha prevents email validation in my form.

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3710
  • View blog
  • Posts: 5,958
  • Joined: 08-June 10

Re: The generated captcha prevents email validation in my form.

Posted 11 June 2012 - 12:33 PM

You've got two <input> elements in that form with the name "Email", first on line #75 and second on line #125. There should only be one. - I'm guessing the one on line #75 isn't supposed to be there.
Was This Post Helpful? 1
  • +
  • -

#3 elbee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 28-September 10

Re: The generated captcha prevents email validation in my form.

Posted 11 June 2012 - 12:39 PM

View PostAtli, on 11 June 2012 - 02:33 PM, said:

You've got two <input> elements in that form with the name "Email", first on line #75 and second on line #125. There should only be one. - I'm guessing the one on line #75 isn't supposed to be there.


You are correct...the one on line 75 was not supposed to be there. I removed it; however, it did not correct the problem. Thanks, Elbee
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1