R: Customizable submit error messages
"Luca Notari" <[email protected]> Fri, 8 Feb 2008 16:06:33 +0100
| Newsgroups | gmane.comp.apache.mod-survey.general |
|---|---|
| Message-ID | <000601c86a64$313b68b0$9e02a8c0@asus01> |
Joel, this is a great feature, solving many problems server-side;
I'm using the ACCESSJS ACCESSFUN attributes in survey tag for error
control, and I've build a little javascript library with functions, that
has the advantage that the error is shown in the same page, capturing
onsubmit event. I can submit it to the list if this can be useful.=20
Dealing with this argument, I've noticed that some people leave surveys
uncompleted for more than 1 hour... So if in multipage, session expired,
and previous answer are marked as 999; I used this as alert for the user
(after, for example, 5 minutes of inactivity)=20
<SCRIPT LANGUAGE=3D"JavaScript">
function forewarnAboutTimeout() {
alert("You are taking more than X minutes... Please complete in 1
hour");
}
function warnAboutTimeout() {
window.location=3D"./timedOut.html";
}
setTimeout("forewarnAboutTimeout()", 1000*60*5);
setTimeout("warnAboutTimeout()", 1000*60*60);
</script>
-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Joel
Palmius
Inviato: venerd=EC 8 febbraio 2008 15.24
A: survey discussion list
Oggetto: survey-discussion-list: Customizable submit error messages
For the upcoming -pre release I have added the option to customize error
messages. By using the new SUBMITERROR tag you can display your own html
code if a specific error happens. A short example:
<SURVEY TITLE=3D"test">
<MATRIX NAME=3D"matr" CAPTION=3D"matrix" MUSTANSWER=3D"yes">
<MATRIXCOLUMN VALUE=3D"1" CAPTION=3D"1" />
<MATRIXCOLUMN VALUE=3D"2" CAPTION=3D"2" />
<MATRIXCOLUMN VALUE=3D"3" CAPTION=3D"3" />
<MATRIXROW CAPTION=3D"a" />
<MATRIXROW CAPTION=3D"b" />
<MATRIXROW CAPTION=3D"c" />
</MATRIX>
<SUBMITERROR CODE=3D"2">
<html>
<body bgcolor=3D"#AAAAFF">
<h1 style=3D"color: #FF0000;">Whups!</h1>
You know, there's this matrix (with caption "$caption") that
has
a row with the question text "$rowcaption". I'd really like you
to answer that, so please press back in your browser and do so.
</body>
</html>
</SUBMITERROR>
</SURVEY>
The "CODE" parameter is the submit error code. The following errors
might=20
be interesting to override with a SUBMITERROR:
2: The question must be answered
7: Answer must be numerical
8: Cannot be higher than
9: Cannot be lower than
10: Not valid (happens when answers must be unique on both col and row
in=20
a matrix)
You can write messages for the other codes too, but those are more
system=20
errors (such as "cannot connect to database" and similar).
The html body may contain a number of variables which will be parsed.=20
These are:
$caption: the CAPTION parameter of the tag
$rowcaption: the CAPTION parameter of the MATRIXROW (if applicable)
$tagnumber: the number of the tag in the page
$name: the variable name
$shortdesc: the error message that would be displayed if you didn't
write=20
your own SUBMITERROR.
This code is in SVN if you are eager to test. Otherwise a -pre release=20
should be available soon.
// Joel
Skickat av Joel Palmius <[email protected]>
till survey-discussion
Skickat av "Luca Notari" <[email protected]>
till survey-discussion