"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)
No it isn't if you use regular expressions. And javascript supports
them out of the box (vesion 1.2+)
> * others? (I have a couple in mind for special purposes,
>   and I would like these classes to provide a "framework"
>   for this functionality)
Dates, zip codes and the like would be nice too.

> 
> 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.

Take a look at that: 
-------------------------------------------------------------------------------
<form name="theForm">
   <input type="text" name="id"> $fieldValidator.add("theForm","id","numeric")
   <input type="text" name="name"> $fieldValidator.add("theForm","name","text")
   <input type="text" name="date"> $fieldValidator.add("theForm","date","date")
   <input type="text" name="partno"> 
$fieldValidator.add("theForm","partno","custom","[A-Z]{2}[1-9]{3,6}")
</form>
...
<script language="javascript">
// your js code here
   function submit()
   {
        var validationStatus;
        var validationMessage;

        $fieldValidator.customizeMessage("Field "," is not valid!");
        $fieldValidator.customizeVars("valiadationStatus","validationMessage"); 
        $fieldValidator.generateCode();

        if(!validationStatus) {
             alert(validationMessage);
        } else {
             document.theForm.submit();
        }
   }
</script>
-------------------------------------------------------------------------------
That's my idea of doing what you propose. I think it's rather self-explantory. 
I don't claim it's perfect, but it's faily easy to implement.
> 
> 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?

As far as I know Turbine doesn't concern itself with Javascript at all.
The WM context tools that you define can output any strings you see fit,
therefore dynamical creation of javascript is easy.

Have fun!

Rafal


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to