RE: CUSTOM and SUBMIT

"Dietrich J Kappe" <[email protected]> Tue, 15 Nov 2005 10:28:51 -0500
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <[email protected]>
 

> -----Original Message-----
>  Joel Palmius wrote:
> > > 1. Is there a prefered way to repopulate the values of fields in a 
> > CUSTOM tag? Trying to insert variables the first time 
> through doesn't seem to work.
> > Time for some preparse perl snippets?
> 
> I don't understand what you mean by "repopulate". Did you 
> have earlier data?

If I submit and encounter a validation error, going back to the previous
page will have all of my previously submitted fields as blank. I'd like to
set the value or checked so that I have the previously submitted values in
there. Is there a preferred way to do this, or do I have to write some perl?
(not a problem; I go all the way back to perl 3. ;-))

> > 2. I've been eyeing the SUBMIT tag for a way of further validating 
> > fields, for example, if a field is supposed to be a 
> zipcode, I'd like 
> > to check if it is 5 digits. If not, I want to issue an 
> error and drop 
> > into the usual mod_survey error handling.
> >
> > Could there be an opportunity for a validation component here?
> 
> I think I did some basic code here actually. Idea was that 
> return value of a perl snippet should decide if the commit 
> was acceptable. I don't think this works though.
> 
> However, I'd recommend validating at the time of input. You 
> can make a CUSTOM with a variable, which implements a text 
> field with javascript checking of the input. You can trigger 
> the check on an onExit from the text field, and clear it if 
> the input is erronous.

Sure. I've used various forms of javascript validation over the years and
will likely use it as a first line of defense, but my typical surveys are
huge instruments with very low completion percentages. I'd hate to lose an
observation because some farmer (or stock broker or doctor) had javascript
turned off.
 
> Possibly you could also override the onSubmit event for the 
> form of the page to perform extra javascript checks. I 
> haven't looked into how this could be done.

Is there a way to insert something into the body onload event? Then I can
use the DOM to insert an onsubmit event myself.

> > One suggestion for an improvement: rather than pop to a 
> seperate page 
> > that tells you that you have a problem and encourages you 
> to hit the 
> > back button, why not just redisplay the survey page with a 
> little error message up top?
> > If not, then at least give the user a back link on the page:  <a 
> > href="javascript:history.back(1)">back</a>
> 
> Yup, exists and looks pretty ok in devel branch.

Sweet.

I have a hacked together mod of Matrix.pm to allow an "Other field." Can't
say it's ready for prime time. Any suggestions for sending it in?

DJK

Skickat av "Dietrich J Kappe" <[email protected]>
till survey-discussion