OpenWGA 7.6 - WebTML reference

WebTML tags » input

<tml:input validation ="tmlscript-expression">

Purpose:

Specifies a validation expression which will be evaluated when the TML form is stored.

Description:

Within the attribute "validation" each input field can define a validation rule for the values entered in this field. The specified expression is automatically evaluated if the form should be stored.If the expression evaluates to 'false' the field is marked invalid and the save process will be canceled.

A form validation can also be done manually via tmlform.validate().

For each validation a message can be defined within the attribute 'message'. These messages can either be displayed by <tml:formmessages> or accessed via TMLScript by calling tmlform.getMessage().

The validation expression can be any TML script. In addition to the default environment the following variables will be provided for validation:

$E_VALUE: contains the user entered value of the field. The value is always of type string or in case of multi value fields a list of strings.

$P_VALUE: contains the "parsed" value of the field. This is the value after the field convertion for e.g. the format has been applied on number or date inputs. The type of $P_VALUE depends on the input type. For e.g. you will recieve a date object here on date input field, or a number on number input fields. If the user entered value could not be parsed $P_VALUE will be null.

Multiple validation rules can be delimited by the specified delimiter within the attribute 'validationdivider'. For each validation rule must have its own message. Messages are also delimited by 'validationdivider' then.

For global form validations which are not related to a single field the <tml:validate> tag can be used.

Value(s):

A TML script expression which evaluates to 'true' or 'false'

Examples:

A simple text field validation:
<tml:input name="firstname" trim="true" validation="($E_VALUE != '')"  message="Please enter your firstname."/>

A date field validation:
<tml:input name="startdate" type="date" validation="($P_VALUE != null)" format="MM/dd/yyyy" message="Please enter a valid date value in format 'MM/dd/yyyy'."/>