I'm not sure Turbine want's javascript libraries. But I have a working
library that does want you want. It's based loosely on one of netscape's
javascript libraries. My goals were to make it extremely easy to
add client checks without having to clutter up the html with gobs of
javascript code.
Here's what you do as a client:
// include the header for the library
<head>
<SCRIPT LANGUAGE="JavaScript1.2"
SRC="FormVerify.js">
</SCRIPT>
</head>
// load the form initializer
<BODY onLoad="initNewAccount()">
// build the form initializer
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
function initNewAccount()
{
var form = document.testForm;
var e;
// one per field that you want to check
// the checkInput objects are found in the library
// the 1st parameter is the form element
// the 2nd is the Label
// the 3rd is if no input for the field is valid (nulls ok)
// all the objects require javascript1.2 since it uses the RegEx objects
// the name in "" must be the name used in the form input
// when using WebMacro, you can use variables to hold these names
// so you don't need to repeat yourself
e = form.elements["email"];
e.checkInput = new EmailAddress(e, "Email", false);
e = form.elements["password"];
e.checkInput = new AlwaysTrue(e, "Password", false);
e = form.elements["alias"];
e.checkInput = new OnlyLetters(e, "Alias", true);
// there's objects for USAPhone, USAStateAbbr, etc
// a lso, if you have a very specific check
// (e.g only 3 characters long, [0-9]+[a-b]*[0-9]+ )
// you can just add the new object to do the checking in your
// own private library and reuse it
//
}
//-->
</SCRIPT>
// now you do your form stuff
// each field is pretty much clutter free of code
<FORM NAME="testForm" ....>
<INPUT TYPE="text" NAME="email" Value=""
onChange="validateTextField(this.checkInput);"
>
// note that the fields are checked after data is entered in each one
// it's optional
..
// this one cycles through all the fields just before submiting
// this should be here whether or not you use the above per field checking
<INPUT TYPE="SUBMIT" NAME="ACTION", Value="Create my account"
onClick="checkAll(this.form); return false;"
>
// that's it
mike
On Mon, Aug 07, 2000 at 11:31:28AM -0400, Diethelm Guallar, Gonzalo wrote:
> Hello,
>
> I would like to have a set of utility classes to generate
> client-validated input fields, using Javascript. I'm
> thinking of:
>
> * number-only fields
> * text-only fields
> * masked input (this one could be hard in general)
> * others? (I have a couple in mind for special purposes,
> and I would like these classes to provide a "framework"
> for this functionality)
>
> The utility classes would do the following:
>
> * Generate the Javascript code only if the browser supports
> Javascript, otherwise just generate a simple input field.
> * Check that any supporting Javascript functions are only
> generated once per page.
> * In version n+1, read the Javascript code from external
> files.
>
> The usage would be something like:
>
> $fieldGenerator.create("numeric", "total");
> $fieldGenerator.create("alphabetic", "name");
>
> maybe passing other parameters (form name, etc.) that might
> be needed by the JavaScript.
>
> I am wondering if this would be the right approach to this
> problem, and if so, whether there would be interest in me
> taking a whack at implementing it. If so, where would this
> go in the Turbine hierarchy? Or perhaps this is already
> there, deep in the bowels of Turbine?
>
> Thanks,
>
>
> --
> Gonzalo A. Diethelm
> [EMAIL PROTECTED]
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?: [EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]