|
|
Documentation Wiki > ExactTarget > Subscribers > Smart Capture > Javascript and Smart Capture > Using Javascript to Validate Fields in a Smart Capture Form
Using Javascript to Validate Fields in a Smart Capture FormFrom $1(Click the banner to go to the related Docs.Code.ExactTarget.com page.) This document contains conceptual and procedural information about using JavaScript to validate fields in a Smart Capture form. What is Using JavaScript to Validate Fields in a Smart Capture FormYou can use Javascript to validate fields and ensure subscribers enter information into the required fields. This JavaScript helps ensure that the information entered in the fields meet the requirements of the field to which that information will be saved. Why Use JavaScript to Validate Fields in a Smart Capture FormBy using JavaScript, you can ensure that you get correct and valid information entered into your Smart Capture form. The form rejects incorrect or incorrectly formatted information and allows only valid entries. How to Use JavaScript to Validate Fields in a Smart Capture FormInsert the code in the HTML window of the content editor in order to include this functionality of your page. The screen and sample code shown below shows the JavaScript used to validate the subscriber's first name, last name, and email address. If any of these fields are left blank, the JavaScript prompts the user to enter the information before continuing.
<form name="myform" method="post" action="%%= RequestParameter('PAGEURL') =%%" onsubmit="return validate()">
<script type="text/javascript">
function validate()
{
var fname=document.getElementById("FirstName").value;
var lname=document.getElementById("LastName").value;
var femail=document.getElementById("Email").value;
submitOK="true";
if (fname.length<1)
{
var Valert = "Please Enter your First Name \n";
submitOK="false";
}
else
{
var Valert = "";
}
if (lname.length<1)
{
Valert = Valert + "Please Enter your Last Name \n";
submitOK="false";
}
if (femail.length<1)
{
Valert = Valert + "Please Enter your Email Address \n";
submitOK="false";
}
if (submitOK=="false")
{
alert(Valert);
return false;
}
}
</script>
This page was last updated by Ryan Williams on Tue, 31 Jan 2012 13:24:24 GMT. If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:
Tags: (Edit tags)
|
Powered by MindTouch 2010 |