Hello,

I have been using HTML::Template for a number of projects and believe some
of the techniques I am using to display the templates could be better
implemented.

The issue in mind is performing some kind of server side validation on data
posted from a standard form. For the sake of simplicity, lets assume that we
are validating whether or not the field contains any kind of data. A sample
of the implementation is below:

<form.html posting to validate.pl>

<form>
...
...
<input size=25 name=Address1 value='<TMPL_VAR NAME="Address1">'>
...
</form>

</form.html>

<validate.pl>

$q = new CGI();
template = HTML::Template->new(filename => $form_page);
%uservalues = $q->Vars;
foreach $key (keys(%uservalues)) {
        if (!$q->param($key))
           $template->param($key => $uservalues{$key});
        }
}
print $q->header();
print $template->output;
</validate.pl>


This works just fine if there are only text fields on the page. For select
fields, radio, or checkboxes I start implementing javascript code to update
the controls with the selected items. I simply update the page with the
javascript and print the TMPL_VAR at the appropriate location:

var list=document.forms['mainform'].elements['hours_1st'];
        for (i=0;i<list.options.length;i++)
          if (list.options[i].value == "<tmpl_var name=hours_1st>")
                list.options[i].selected = true;



This gets very lengthy and cumbersome as for each element I must implement
javascript.

Is there a better way to implement server side validation? Please keep in
mind that I would like designers, clients, etc be able to update the page
(specifically drop down values) without the need for me to add the item to
the code.

Any comments will be helpful.


Roy Rubin
[EMAIL PROTECTED]
http://www.irubin.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to