Validation Not Working...
I have rebuilt this over and over again with different values using the toolkit and cannot get anything to validate... Can anyone offer a suggestion as to what is going on?
I am using Validation Toolkit v2.3.5 on Dreamweaver CS4 (OSX). This is simple code for a standalone page and is not yet integrated with Universal Email 3.0.6 but that is the plan once I get this working.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contact Seller</title>
<script type="text/javascript">
<!--
function WAAddError(formElement,errorMsg,focusIt,stopIt) {
if (document.WAFV_Error) {
document.WAFV_Error += "\n" + errorMsg;
}
else {
document.WAFV_Error = errorMsg;
}
if (!document.WAFV_InvalidArray) {
document.WAFV_InvalidArray = new Array();
}
document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
if (focusIt && !document.WAFV_Focus) {
document.WAFV_Focus = focusIt;
}
if (stopIt == 1) {
document.WAFV_Stop = true;
}
else if (stopIt == 2) {
formElement.WAFV_Continue = true;
}
else if (stopIt == 3) {
formElement.WAFV_Stop = true;
formElement.WAFV_Continue = false;
}
}
function WAValidateAN(formElement,value,errorMsg,allowUpper,allowLower,allowNumbers,allowSpace,extraChars,focusIt,stopIt,required) {
var isValid = true;
extraChars = extraChars.replace(/"/g,'"');
if ((!document.WAFV_Stop && !formElement.WAFV_Stop) || formElement.WAFV_Continue) {
for (var x=0; x<value.length; x++) {
var charGood = false;
var nextChar = value.charAt(x);
var charCode = value.charCodeAt(x);
if (allowLower) {
if (charCode >= 97 && charCode <= 122) {
charGood = true;
}
}
if (allowUpper) {
if (charCode >= 65 && charCode <= 90) {
charGood = true;
}
}
if (allowNumbers) {
if (charCode >= 48 && charCode <= 57) {
charGood = true;
}
}
if (allowSpace) {
if (nextChar == " ") {
charGood = true;
}
}
if (extraChars) {
if (unescape(extraChars).indexOf(nextChar) >= 0) {
charGood = true;
}
}
if (!charGood) {
isValid = false;
x = value.length;
}
}
if (required && value=="")
isValid = false;
}
if (!isValid) {
WAAddError(formElement,errorMsg,focusIt,stopIt);
}
}
function WAtrimIt(theString,leaveLeft,leaveRight) {
if (!leaveLeft) {
while (theString.charAt(0) == " ")
theString = theString.substring(1);
}
if (!leaveRight) {
while (theString.charAt(theString.length-1) == " ")
theString = theString.substring(0,theString.length-1);
}
return theString;
}
function WAFV_GetValueFromInputType(formElement,inputType,trimWhite) {
var value="";
if (inputType == "select") {
if (formElement.selectedIndex != -1 && formElement.options[formElement.selectedIndex].value && formElement.options[formElement.selectedIndex].value != "") {
value = formElement.options[formElement.selectedIndex].value;
}
}
else if (inputType == "checkbox") {
if (formElement.length) {
for (var x=0; x<formElement.length ; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (formElement.checked)
value = formElement.value;
}
else if (inputType == "radio") {
if (formElement.length) {
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (formElement.checked)
value = formElement.value;
}
else if (inputType == "radiogroup") {
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
value = formElement[x].value;
break;
}
}
}
else if (inputType == "iRite") {
var theEditor = FCKeditorAPI.GetInstance(formElement.name) ;
value = theEditor.GetXHTML(true);
}
else {
var value = formElement.value;
value=value.replace(/<p>(\&\#160\;)*<\/p>/,"");
}
if (trimWhite) {
value = WAtrimIt(value);
}
return value;
}
function WAValidateRQ(formElement,errorMsg,focusIt,stopIt,trimWhite,inputType) {
var isValid = true;
if (formElement.length && inputType.toLowerCase()!="radio" && inputType.toLowerCase()!="select") formElement=formElement[0];
if (!document.WAFV_Stop && !formElement.WAFV_Stop) {
var value=WAFV_GetValueFromInputType(formElement,inputType,trimWhite);
if (value == "") {
isValid = false;
}
}
if (!isValid) {
WAAddError(formElement,errorMsg,focusIt,stopIt);
}
}
//-->
</script>
</head>
<body>
<form action="" method="post" onsubmit="WAValidateAN(document.forms[0].First_Name,document.forms[0].First_Name.value,'- Invalid character in entry',true,true,false,true,'',document.forms[0].First_Name,0,true);WAValidateRQ(document.forms[0].First_Name,'- Entry is required',document.forms[0].First_Name,0,false,'text');WAValidateAN(document.forms[0].Last_Name,document.forms[0].Last_Name.value,'- Invalid character in entry',true,true,false,true,'',document.forms[0].Last_Name,0,true);WAAlertErrors('The following errors were found','Correct invalid entries to continue',true,false);return document.MM_returnValue">
<table width="600" border="0">
<tr>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
<tr>
<td><label>First Name </label></td>
<td><input name="First_Name" type="text" value="" /></td>
</tr>
<tr>
<td><label>Last Name </label></td>
<td><input name="Last_Name" type="text" value="" /></td>
</tr>
<tr>
<td><label>E-Mail Address </label></td>
<td><input name="Email" type="text" value="" /></td>
</tr>
<tr>
<td><label>Telephone </label></td>
<td><input name="Telephone" type="text" value="" /></td>
</tr>
<tr>
<td><label>Question </label></td>
<td><textarea name="Question" cols="60" rows="5" wrap="virtual"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input name="Submit" type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>