🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.golive.dynamic.content
Article #35

Re: Form Validation with dynamic content

#35
From: Patrick_Schreifels
Date: Fri, 25 Jun 2004 22:38
21 lines
1804 bytes
Use Jerry's JavaScript suggestion. Validating a field(s) that has been bound to a content source can be tricky. You must address each form element by its elements number. So each validation line will resemble :

if (document.FORMNAME.elements[X].value =="") [then do something];

...where FORMNAME is the name of the form and X is the element number.

To see a list of elements, click the Objects tab in the Inspector when you have a JavaScript window open. Then expand:: document-->FORMNAME-->elements.

Here's an example of a validation script that I use:

function validate() {
  var alertMessage = "The following required fields have been left empty:\n";
  if (document.Contact.elements[1].value == "") alertMessage += "\nTitle";
  if (alertMessage != "The following required fields have been left empty:\n") {
     alertMessage += "\n\nPlease fill out all required fields and try again.";
     alert(alertMessage);
     return false;
  } else return true;
}

Then call the function (don't use GoLive Actions) by including an onsumbit trigger in the /<form/> tag, like this: onsubmit="return validate(this)"
Technical Details
Message-ID: <3bb4c0da.6@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.agarik.com!news.agarik.com!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <3bb4c0da.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11ffd2,f92e0d40e787fa73
X-Google-Attributes: gid11ffd2,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Patrick_Schreifels@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.agarik.com!news.agarik.com!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.golive.dynamic.content
Subject: Re: Form Validation with dynamic content
Message-ID: <3bb4c0da.6@webx.la2eafNXanI>
Date: Fri, 25 Jun 2004 15:38:44 -0700
References: <3bb4c0da.-1@webx.la2eafNXanI>
Lines: 31
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit