close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Validation Not Working...

Thread began 7/30/2009 7:10 am by BGordon | Last modified 7/30/2009 10:23 am by BGordon | 3657 views | 3 replies

511377038

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(/&quot;/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">&nbsp;</th>
<th scope="col">&nbsp;</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>&nbsp;</td>
<td><input name="Submit" type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...