![]() |
<PowerForms> |
PowerForms is the name of the sub-language in <bigwig> for restricting form field input from the client. Regular expression formats may be defined and bound to input fields in html forms with the semantics that only client input complying with the regular expressions may be submitted. The syntax for adding a format to an input field is:
<format field="FieldName"> <bigwig-regexp idref="FormatName"/> </format> |
The FieldName refers to an input field in the document and the FormatName refers to a declared regexp format. Whenever the above declaration is added to a document, all fields named FieldName are (client-side) validated incrementally against the regular expression. Such "power fields" are compiled into standard html fields with JavaScript ensuring the increased functionality. The effect of adding a format to a text field is that the client will check (through JavaScript interpreting deterministic finite automata) that the contents of the field complies with the associated regular expression. The result of adding a format to a radio, select, or checkbox is that invalid choices cannot be depressed/selected.
As long as there are fields that do not comply with their associated formats, the html page cannot be submitted and a suitable error message will be given. This form input validation will be performed incrementally (that is, as the client enters the data) and the results will be visualized in a dynamically updated image next to text and password input fields. At any point in time, this image will show one of three images (corresponding to the current state of the deterministic finite automaton):
The three images default to a traffic-light style as shown below:
| The field accepts strings with zero, three, or six characters. |
For reasons of security the fields are double checked at reception time on the server-side.
The value of the error string is shown in the browser's status bar when the input is neither in the language defined by the regular expression, nor in the prefix of this language. The value of the warning string is shown in the status bar when the input is in the prefix of the language defined by the regular expression, but not (yet) in this language itself.
The format element may take an error="..." and a help="..." attribute. The value of the error attribute is the error message displayed when the client attempts to submit a page with illegal input. The help value is displayed in the browser's status bar when the field is in focus.
The regular expressions bound to fields are allowed to be interdependent. This means that a format that applies to a given field may depend on the values of other fields. Technically, the specification of a format is now a binary decision tree, whose leaves are regular expressions and whose internal nodes are boolean expressions. Each boolean expression is a propositional combination of the primitive match and equal elements that each test the field indicated by the name attribute. A format declaration now has the following syntax:
| formatdecl | : | format |
| | | <format field=stringconst | |
| [help=stringconst] | ||
| [error=stringconst]> | ||
| format | ||
| </format> | ||
| format | : | regexp |
| | | <format id=stringconst> | |
| format | ||
| </format> | ||
| | | <format idref=stringconst/> | |
| | | <if> boolexp | |
| <then> format </then> | ||
| <else> format </else> | ||
| </if> | ||
| boolexp | : | <match field=stringconst> |
| regexp | ||
| </match> | ||
| | | <equal field=stringconst | |
| value=stringconst/> | ||
| | | <and> boolexp* </and> | |
| | | <or> boolexp* </or> | |
| | | <not> boolexp* </not> | |
This mechanism also allows formats to be defined dynamically in the html pages. This can be done with the <format id="...">...</format> element. Such dynamically defined formats can then be referenced in other formats using the <format idref="...">/ element.
The submission blockage caused by fields not complying with their associated formats can be overridden by setting the value of the ignoreformats attribute to "yes". This attribute will only make sense for buttons that cause a page to be submitted (i.e. submit-buttons, <continue>, and input-images). Note: for backwards compatibility the attribute can occur without a value, which is equivalent to setting the value to "yes".
|
bigwig@brics.dk Last updated: November 2, 2001 |
|