wiki:Developer/KHIS2/ValidationDeveloper

Validation

boolean, checkbox, file, formatNumber, list, password, radio, richtext, textarea elements

If value is required, specify <required>true</required>
If <required> is not specified, or is set to anything other than true, the element won't be validated as required.

email element

Value will be automatically validated as an email address.
If value is required, specify <required>true</required>
If <required> is not specified, or is set to anything other than true, the element won't be validated as required.

dateFormat element

Uses JavaScripts built-in Date to test if the date is valid, and therefore applies no sanity checks. Only the format must be valid, not the actual date, eg 30/30/2008 is a valid date.
If value is required, specify <required>true</required>
If <required> is not specified, or is set to anything other than true, the element won't be validated as required.

numberFormat element

Value will be automatically checked as being numeric.
If value is required, specify <required>true</required>
If <required> is not specified, or is set to anything other than true, the element won't be validated as required.

text element

If value is required, specify <required>true</required>
If <required> is not specified, or is set to anything other than true, the element won't be validated as required.

  • To validate value as email address, specify <validation>email</validation>
  • To validate value as decimal number, specify <validation>number</validation>
  • To validate value as url, specify <validation>url</validation>
  • To validate value as date, specify <validation>date</validation> (NB uses Javascripts built-in Date to test if the date is valid - see dateFormat notes above)

moneyFormat element

  • Value will be checked to ensure that it is to a maximum of 2 decimal places - e.g. 12.345 will be invalid, whereas 12.34 is valid
  • If only positive values are required, specify <validation>positive</validation>
  • If only negative values are required, specify <validation>negative</validation>
  • If either positive/negative values are required, just leave <validation></validation> blank
  • If value is required, specify <required>true</required>
  • If <required> is not specified, or is set to anything other than true, the element won't be validated as required.
Last modified 2 years ago Last modified on 17 Sep 2015 10:07:13