Jump to content


image button doesn't submit form, but hitting enter does

  • Please log in to reply
2 replies to this topic

#1 toolman


    Advanced Member

  • Members
  • PipPipPip
  • 173 posts

Posted 19 July 2013 - 06:41 AM



I have the following code for a newsletter signup. The form works when the user enters their email address and hits enter, but if the submit the form using the image or a link, it prompts them with a message saying the email address is invalid.


Any ideas what would cause this?





(function(a){var b={g:function(){var d=document.cookie.split(";");for(var e=0;e<d.length;e++){var f=d[e];while(f.charAt(0)==" "){f=f.substring(1,f.length)}if(f.indexOf("euCookieLaw")==0){return f.substring("euCookieLaw".length,f.length)}}return null},s:function(d){var c=new Date();c.setTime(c.getTime()+315532800000);document.cookie="euCookieLaw="+d+"; expires="+c.toGMTString()+"; path=/"}};a.extend({cookieLaw:function(c){var e={impliedConsent:true,title:"Our Cookie Policy",shortMessage:"<h3>Sign up for Special Offers</h3><p><img src=\"/beta/images/small_tick.png\" /> Discount Codes and Promotions<br /><img src=\"/beta/images/small_tick.png\" /> Receive Special Offers<br /><img src=\"/beta/images/small_tick.png\" /> Latest News and Competitions</p><p><strong>Enter your email to signup:</strong></p><form action=\"action.php" method=\"post\" id=\"newsletter_form\"><input type=\"text\" id=\"email\" onfocus=\"javascript:this.value =(this.value == 'Your email address...')?'':this.value;\" onblur=\"javascript: this.value=(!this.value)?'Your email':this.value;\" class=\"email\" maxlength=\"4000\" name=\"EMAIL\" value=\"Your email\" size=\"23\" /><a href=\"#\" onclick=\"var form = document.getElementById('newsletter_form'); Marketing.OptIn(form); return false\" title=\"Sign Up for offers\" class=\"button\">signup</a><input type=\"hidden\" name=\"EMAIL_REQUIRED\" value=\"T\" /><input type=\"hidden\" name=\"EMAIL_DATATYPE\" value=\"email\" /><input type=\"hidden\" name=\"agent_code_REQUIRED\" value=\"T\" /><input type=\"hidden\" name=\"agent_code_DATATYPE\" value=\"text\" /><input type=\"hidden\" id=\"newsletter_agentCode\" name=\"agent_code\" value=\"$ref_code\" /></form>",longMessage:"Cookies are small text files held on your computer. They allow us to give you the best browsing experience possible and mean we can understand how you use our site.",onAccepted:function(){}},d=b.g();c=a.extend(e,c);if(d==null){a.notify({inline:true,html:"<h3>"+c.title+"</h3><p>"+c.shortMessage+'</p><p id="euCookieLongMessage" style="display: none;">'+c.longMessage+'</p><p id="euCookieButtonContainer">'+(!c.impliedConsent?'<a id="euCookieAccept" class="btn primary" href="#">I Accept</a>':"")+' <a class="btn" id="euCookieMoreInfo" href="#">More Info</a> </p>',close:(!c.impliedConsent?a("#euCookieAccept"):"Close"),onComplete:function(){a("#euCookieMoreInfo").click(function(){if(a("#euCookieLongMessage").is(":hidden")){a(this).text("Less Info");a("#euCookieLongMessage").fadeIn(250);a.notify("resize",a(this).parents(".notification"))}else{a(this).text("More Info");a("#euCookieLongMessage").fadeOut(250,function(){a.notify("resize",a(this).parents(".notification"))})}});if(c.impliedConsent){b.s("implied");c.onAccepted.call(this)}},onCleanup:function(){b.s("accepted");c.onAccepted.call(this)}})}else{c.onAccepted.call(this)}}})})(jQuery);

Edited by toolman, 19 July 2013 - 06:43 AM.

#2 cyberRobot


    Advanced Member

  • Gurus
  • 1,995 posts

Posted 19 July 2013 - 07:25 AM

It's difficult to tell what's going on since code doesn't have any line breaks. One issue that I noticed, however, is that the following has an unescaped double quote:


<form action=\"action.php" method=\"post\"


I'm not sure if that would cause the problem you describe though...

Blogging about PHP and other web-related topics at ScorpBytes.com

#3 toolman


    Advanced Member

  • Members
  • PipPipPip
  • 173 posts

Posted 19 July 2013 - 07:41 AM

Thanks, It does actually have an escape, I must have removed it when posting to remove the actual url.


Any ideas what would cause the issue?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime