Webcollect - Advanced example

Example Webcollect form - this can be automatically generated from the eMail Networks Interface, under Tools->Site Visitor Signup Box

Webcollect form
<SCRIPT language="Javascript"> 
<!-- 

//ENTER ALL THE REQURED FIELDS NAMES HERE
var rfnames=new Array(); 
var rfdesc=new Array(); 


// isEmail (STRING s [, BOOLEAN emptyOK])
// whitespace characters
var whitespace = " \t\n\r";

// 
// Email address must be of form a@b.c ... in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
function isValidEmail(s)
{   
    if (isEmpty(s)) return false;
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
        
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// Check whether string s is empty.
function isEmpty(s)
{   
    return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.
function isWhitespace(s)
{   
    var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we dont, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isnt whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

function checkForm() { 
    var message = "";
    
    if (!isValidEmail(document.subscribeForm.elements['EmailAddress'].value)) {
    document.subscribeForm.elements['EmailAddress'].style.backgroundColor='yellow';
        //alert("Please enter a valid Email Address. (yourname@domain.com)");
        message = "Please enter a valid Email Address. (yourname@domain.com)\n\r" ;
        document.subscribeForm.elements['EmailAddress'].focus();
        
    }
    
    
    for(var i=0; i<rfnames.length; i++) { 
        if (document.subscribeForm.elements[rfnames[i]].value == "") {
        document.subscribeForm.elements[rfnames[i]].style.backgroundColor='yellow';
        message = message + rfdesc[i] + " is required \n\r";
        }
    }

    if (message.length > 1) { 
        alert(message);
        return false;
    }

}





//--> 
</SCRIPT>
<form action="http://portal.emailnetworks.com/wc/wc.cfm" name="subscribeForm" method="post" onSubmit="return checkForm();">
<table width=500 border=0 align="center" cellpadding=3 cellspacing=0 style="border: 2px solid #000000; padding: 8px;">
<tr><td> <img border="0" src="http://portal.emailnetworks.com/images/logo.jpg" /></td></tr>

<input type="hidden" name="thankyou" value="http://portal.emailnetworks.com/wc/thankyou.cfm">
<input type="hidden" name="err" value="http://portal.emailnetworks.com/wc/error.cfm">
<input type="hidden" name="Action" value="sub">
<input type="hidden" name="LID" value="123">
<input type="hidden" name="MID" value="123">
<tr>
  <td>
  <table width=500 border=0 align="center" cellpadding=3 cellspacing=0 style="border: 1px solid #cccccc; padding: 8px;">
          <tr> 
          <td align="center">You can subscribe to our mailing list by filling out the form below and clicking on the "Subscribe!" button.
          </td></tr>
          <tr>
            <td align="center"> <table width="100%" border="0" cellpadding="3" cellspacing="0">          
                   <tr> 
                  <td width="35%" align="right"><font color="#333333" face="Arial, Helvetica, sans-serif"><strong><font color="#990000">*</font>Email 
                    Address: </strong></font></td>
                  <td width="65%"><div align="left"><font face="Arial, Helvetica, sans-serif"> 
                      <input type="text" size="30" name="EmailAddress">
                      </font></div></td>
                </tr>

				<tr> 
                  <td colspan=3 width="100%" align="left">Please select your lists of interest</td>
                </tr>
				<tr> 
                  <td colspan=3 width="100%" align="left"><input type="checkbox" name="LID" id="2458387102" value="2458387102"> test list  12-18-12</td>
                </tr>
				<tr>
					<td colspan=3>   <p align="center"> <font face="Arial, Helvetica, sans-serif"> 
                      <input name="submit" type="submit" value="Subscribe!">
                      </font></p></td><tr>                 
              </table>
              </td>
          </tr>
        </table>
  </td>
</tr>
</table>
</form>