GetResponse logo by Implix.It’s great that GetResponse gives you the code to add a web sign up form to your opt in page, but they forgot to add some sort of form field validation. I’m going to share with you the javascript code I use to validate my GetResponse form fields so that my subscribers don’t accidentally hit the subscribe button with an empty form field. This mainly comes in handy if you pay affiliates to sign up, you’ll want to make sure the form is at least filled in with something before submission.

I like to use javascript to validate the form fields because it doesn’t mess with the GetResponse script in any way shape or form. The only bad thing about using javascript is that your potential subscriber could have it turned off with their current browser which will make the code not work at all. Most people use javascript, so it’s a pretty safe bet that the code will be useful to you.

GetResponse has recently updated their system so your code may be different than mine. If it is, you can simply update your web form in your GetResponse back office. Once that is done, you are going to want to add this javascript code right before the <form> tag.

<script language="JavaScript"> <!-- // ignore if non-JS browser

function Validator(custom_http_referer) { var error = "";

if (custom_http_referer.subscriber_name.value == "") { error += "Please fill in your name.\n"; }

if (custom_http_referer.subscriber_email.value == "") { error += "You must input an email address.\n"; } if ((custom_http_referer.subscriber_email.value.indexOf ('@',0) == -1 || custom_http_referer.subscriber_email.value.indexOf ('.',0) == -1) && custom_http_referer.subscriber_email.value != "") { error += "Please verify that your email address is valid."; } if (custom_http_referer.custom_phone.value == "") { error += "Please fill in a phone number.\n"; }

if (error != "") { alert(error); return (false); } else { return (true); } } // --> </script><form accept-charset="utf-8" action="" onsubmit="return Validator(this);" style="width: 250px; font-family: verdana; background-color: #ffffff; margin: 0px;">

Let me explain a few things:

The Validator function has one argument, (custom_http_referer). All you need to do is add the onsubmit command to the <form> tag to trigger the function.

That’s all there is to it. The code above only checks that a name, e-mail, and phone number have been filled in. You can add more checks to the script or remove unneeded checks as well.

You’ve seen the code, now take a look at the above script’s demo. Don’t fill in one of the form’s fields and you’ll see a javascript alert pop up on your screen and the form will not be submitted.

Tags: , , , , , , , ,

3 Comments to “How to use javascript to make your GetResponse subscription form check fields”

  1. roger mill says:

    Thanks for the javascript info, very helpful.


  2. I see everybody is talking about the java script and the getresponse web form but what about people like us who are using already design web template. How do we embed this web form code from getresponse in to our website so that it will look like the others


  3. this javascript info is very useful thankx for the sharing


Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>