[pmwiki-users] Fox forms and form validation

Scott Smith smackaysmith at gmail.com
Wed Jul 16 00:24:04 CDT 2008

I'm struggling with a form that has validation (an effort to make my forms
right and proper). One of the fields, 'destination', is used to create the
Target page. This field has validation, making sure it isn't too short or
too long and doesn't include funky characters. The validation works; the
creating of the page works. However, if an invalid character causes the
validation to fail, the page displays the 'destination' field as blank
instead of the value typed in.

For example, I type in 'destination': San Diego/2008. The slash is invalid
and the validation mark-up catches it and re-displays the form. The
'destination' field is now blank. This doesn't happen with my other fields
that have validation. They come back with the failed value (which is what I
want and expect).

Note: I've updated to the latest Fox.

The form mark-up--

(:foxmessages hrtravel list=nocheck:)
(:fox hrtravel put=top target='{$$destination}' ptvupdate=1
template=TravelTemplate#display redirect=1 :)
(:input defaults source={$EditSource} :)
(:input hidden foxnotify HR:)
(:foxcheck name=destination regex='^[a-zA-Z0-9_-\s]{3,40}+$' msg="Only
alphanumeric (at least 3 characters long but less than 40 characters),
underscores, spaces or dashes allowed for destination names.":)

'''Travel Request Page Name:''' (:input text destination "{$:destination}"
size=40:) %red%(:foxmessage hrtravel name=destination:)%%

'''Name(s) of Travelers'''
(:foxcheck name=ptv_traveler1 msg="You must type in one Traveler name.":)
||(:input text name=$:traveler1 size=40:) %red%(:foxmessage hrtravel
||(:input text name=$:traveler2 size=40:)||
||(:input text name=$:traveler3 size=40:)||
||(:input text name=$:traveler4 size=40:)||
||(:input text name=$:traveler5 size=40:)||
||(:input text name=$:traveler6 size=40:)||
(:foxcheck name=ptv_noofattendee regex='[1-6]' msg="The number of Travelers
must be between 1 and 6.":)
Number of Travelers: (:input text name=$:noofattendee size=3:)
%red%(:foxmessage hrtravel name=ptv_noofattendee:)%%

'''Reason for Travel:''' (:input default $:travelreason Client :)
(:input radio $:travelreason Client :) Client visit
(:input radio $:travelreason Conf :) Attending a conference
(:input radio $:travelreason Other :) Other

If a ''Client visit,'' which client(s)? (:input text name=$:clientvisit

If attending a ''Conference,'' which conference? (:input text
name=$:conference size=60:)

(:input default $:regcostper "0":)
(:input default $:airfarecostper "0":)
(:input default $:hotelcostper "0":)
||'''Item''' ||'''Amount'''||
||Conference Registration Per Person ||$(:input text name=$:regcostper
||Airfare Per Person ||$(:input text name=$:airfarecostper size=12:) ||
||Hotel Per Person ||$(:input text name=$:hotelcostper size=12:) ||

(:input hidden name=$:conftotal "{$$noofattendee} * {$$regcostper}" :)
(:input hidden name=$:airtotal "{$$noofattendee} * {$$airfarecostper}" :)
(:input hidden name=$:hoteltotal "{$$noofattendee} * {$$hotelcostper}" :)
(:input hidden name=$:totalcost "{$$noofattendee}*({$$regcostper} +
{$$airfarecostper} + {$$hotelcostper})" :)

(:input submit post Enter:)
(:foxend hrtravel:)

I'm not sure the template is wanted or required, but here it is--

!!!#display for HR Travel Expense Form
(:title {$$destination}:)
>>right messageheader<<
%green%[-created {$$(date:M j, 'y  g a)}-]
>>frame messagetext<<

||border=0 rules=rows frame=hsides
|| ||{$$traveler2}||
|| ||{$$traveler3}||
|| ||{$$traveler4}||
|| ||{$$traveler5}||
|| ||{$$traveler6}||

'''Reason for Travel'''

'''Clients Visited'''

'''Conference Name'''

||Item || Cost Per || Travelers || Totals||
||Conference Total || ${(numfmt {$$regcostper} 2 '.' ',')}||
{$$noofattendee}|| ${(numfmt (calc '{$$conftotal}') 2 '.' ',')}||
||Airfare Total || ${(numfmt {$$airfarecostper} 2 '.' ',')}||
{$$noofattendee}|| ${(numfmt (calc '{$$airtotal}') 2 '.' ',')}||
||Hotel Total || ${(numfmt {$$hotelcostper} 2 '.' ',')}|| {$$noofattendee}||
${(numfmt (calc '{$$hoteltotal}') 2 '.' ',')}||
||Total || || || ${(numfmt (calc '{$$totalcost}') 2 '.' ',')}||



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20080716/08ee6057/attachment.html 

More information about the pmwiki-users mailing list