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
--
KaiMoorfeld - 09 Feb 2007
Answer
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