|
Cookbook /
FormValidationSummary: How to validate forms within wiki pages
Version:
Prerequisites:
Status:
Maintainer: Luigi -> mailto:kirpi [snail] kirpi [period] it
Categories: Forms
QuestionHow can I validate forms within wiki pages? AnswerReal form validation is to be done server-side. Nevertheless client-side validation is still quite useful: you could include a tiny javascript within your pages. Notes
CommentsI am already successfully using a slightly extended version of the scripts/forms.php. It supports a new "validateinput" action that takes _regex and _message arguments passed to (:input:) fields, constructs the $MessagesFmt for invalid fields and focuses the first invalid field via javascript when form validation fails. When a submission is completely valid, it calls a user-defineable function with the form name and the field values. In my environment, that function stores the fields in another page and sends an email with the values. See the article on my personal PmWiki for more details, an example and download. Here is a recipe You can implement form validation using the Javascript script described at JavaScript-Coder.com. (http://www.javascript-coder.com/html-form/javascript-form-validation.phtml)
with:
return FmtPageName("<form name='$name' action='\$PageUrl' method='post'>
Make sure your form recipe also insert form's name in the HTML code.
Replace "mydomain" with your domain...
CheckRadioButton is a custom function to validate Radio Button. You can add as many frmvalidator.addValidation() line as you wish. frmvalidator.setAddnlValidationFunction() just register the CheckRadioButton function.
Pierre Racine, Feb, 2007 WikiSh provides a pretty rich capability for form validation on the server side. See in particular the See the following links for examples:
wForms input validation If you're looking for a hardened secure javascript solution to use, try the free wForms libs from formassembly; http://www.formassembly.com/wForms/v2.0/documentation/input-validation.php(approve links) which I've been using a lot (outside and inside of pmwiki) and has all you need for client-side validation, plus a lot more. Especially if the user already limits access to the pages you use this on, it's pretty darn secure. Julius Thyssen April 2008 See AlsoContributors
|