Formmail validated by HTML (3)

Date 2007-09-06 06:31:17 | Category: XOOPS

in englishin japanese
Here is a document how to validate POST data via pure HTML.


(A) How to get POST's indexes should be received?

Just get "name" attributes in the HTML.
# Though it is difficult to treat array like hobbies[], I skip it now.


(B) How to get field's title?

This system gets field's title from <label> corresponding the <input> from HTML.


(C) How to judge whether the field is essential or not?

This system judges them by their filed's name.
If a field contains '_required' in its name, the field will be regarded as essential.
refer the sample HTML in (1).
The field of 'name_required' is essential.


You can specify validation rule by "class" of <input>. (pico >= 1.51)
refer the sample HTML in (1).
<input> for 'name' has the class of "required".
Then the field will be essential.


(D) How to do "TYPE-SAFE" or "TYPE-AUTO-CONVERSION"?

This "type" contains not only int,double,string etc, but also "telephone number","email address" etc.

This system judges them their filed's name like (C).
eg) if a field contains 'email' in its name, the field will be validated as "email address".


You can specify validation rule by "class" of <input>. (pico >= 1.51)
refer the sample HTML in (1).
<input> for 'email' has the class of "email".
Then the field of 'email' will be checked by the rule of RFC2822.

Of course, you can specify classes multiply.
If an <input> has class="email required", the field will be essential AND validated as "email address".





You can read more news at PEAK XOOPS.
http://xoops.peak.ne.jp

The URL for this story is:
http://xoops.peak.ne.jp/md/news/index.php?page=article&storyid=439