Tags:
create new tag
view all tags

Question

How can I validate form input.

Example: I have a form on my page, which people have t to fill out. Since I use some of the form data to gather some statistics, I need some form fields to be filled. I would like to do a validation of the form input when the user saves the topic with some option to give feedback. Ideally some kind of error message forcing the user to provide the correct data.

How can I achieve this.

Environment

TWiki version: TWikiRelease04x00x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: RHEL 4
Web server: Apache2
Perl version: v5.8.0
Client OS: WinXP
Web Browser: Opera, IE 6, FireFox
Categories: Forms

-- KaiMoorfeld - 09 Feb 2007

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

See TWikiForms documentation on how to declare a form field a mandatory field. A topic cannot be saved if set to M and if the form field is empty. There is currently no fine grained control on validation besides this simple all or nothing flag.

-- PeterThoeny - 10 Feb 2007

Kai, specifying constraints for TWiki forms hasn't been implemented, mostly due to a primary driver ie. someone to keep us developers focussed on the core needed features. If you could help us out, by acting as a customer, and thus defining a core set of use-cases, and to prioritise and keep development going, that would be fantastic!

-- SvenDowideit - 10 Feb 2007

Sven, Sorry for the late reply. I am still in need for such a feature. So what do you expect me to do. Do you have a template for your use cases?

Thanks Kai

-- KaiMoorfeld - 03 Sep 2007

Form validation is implemented in FormPlugin.

-- ArthurClemens - 04 Sep 2007

Hi All, I defined my form with M as an attribute but it still goes through even though the field is empty. Here is the form:

Name Type Size Value Attributes
Project ID text 82    
Status select 1 GRN, YLW, RED  
Stage select 1 In Pipeline, Execution, Eng-Complete, Proj-Complete, Cancelled  
ISV/Community text 82   M
Product & Version text 82   M

Here is my page:

[[IsveDeltaProjects][My Manager's Project Summary]] | %INCLUDE{"%MDE%.SumHeading"}%<br>
<input type="text" name="topic" value="IsveDeltaVietPham<ISV Name><Application Name><Suffix if more than one ISV Name/Application Name combination>" size="135" /<input type="hidden" name="onlywikiname" value="on" />
<input type="submit" value="Create New Project Report" />
<input type="hidden" name="templatetopic" value="IsveProjectFieldLegend" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="formtemplate" value="IsveWWPDeltaForm" />
</form>

-- VietPham - 03 Dec 2007

The 'M' setting is only used for topic forms (see TWikiForms), not for custom forms in a topic. If you need form validation on a custom form, use FormPlugin.

-- ArthurClemens - 03 Dec 2007

Change status to:
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2007-12-03 - ArthurClemens
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.