By default, validators for German-style numbers and dates are available.
To use custom validator for different formats, see below for how to customize validators, as well as the help pages on editing the date format and using different number formats.

Available validators

Name XM_FORM_VRULES Description
Text-Default setting. The input won't be validated. All characters are allowed.
Letters & spacesonlyLetterSpOnly letters (UTF-8) and spaces are allowed, including characters with diacritics (ö, ü, ä, é etc.).
Letters, numbers and spacesonlyLetterNumberOnly letters (UTF-8), numbers, and spaces are allowed, including characters with diacritics (ö, ü, ä, é etc.).
IntegerintegerOnly numbers without a decimal point are allowed, such as 100 or -100.
Positive integerposintegerOnly positive numbers without a decimal, such as 100 or 200.
NumbernumberOnly numbers with a German-style decimal separator (comma) are allowed, such as /100-4,45 or 1,9.
MoneymoneyOnly numbers with exactly two decimals places are allowed. The decimal separator is a comma. Thousands separators are not allowed. For example, both 100 and 99,99 are allowed, but not 1,234 or 456.123,23.
Positive amount of moneyposmoneySame as money, but must not be negative.
Positive amount of money (opt. decimal)posmoneyOptionalCommaSame as money, but does not require two decimal place. For example, 3, 3,4, and 3,49 are allowed, but not 3,493.
EmailemailE-Mail Validator (International email address,eai)
Date(DD.MM.YYYY)datumDEOnly German-style dates are allowed, ie. DD.MM.YYYY. Example: 01.01.2015.
TimetimeAllows only time values of the format hh:mm, such as 01:30 or 13:30.
Postal code(Germany)plzDEOnly German postal codes are allowed, ie. five digits such as 01109 or 01069.
Phone numberphoneOnly phone number are allowed. For example, +49 351 810 500, 0049-351-810-500 and 0049/351/810/500 are allowed, but not numbers such as +49 (0)351 810 500
URLurlOnly valid URLs are allowed, such as http://www.xima.de
, https://www.xima.de
, and ftp://ftp.xima.de
.
IP adressipv4Only IP v4 addresses are allowed, such as 127.0.0.1 and 192.168.0.255.

Client and server side validation

You can enable sever side validation for all form fields supporting data types. By default, server validation is not enabled. When the user enter an invalid value, the browser checks the form field and displays an error message. However, from a technical point of view, it is still possible to submit forms containing invalid data, such as by sending custom POST requests. By enabling server side validation, all submitted forms will be validated on the server. When they fail to validate, the form will not be accepted and an error will be shown.

Do not enable server side validation when overriding validator as described below. When you do, the form will always fail to validate.

Overriding validators

All validators for each data type can be changed by modifying them via Javascript. All validators are contained in the Javascript object window.XM_FORM_VRULES.

To override validators, you can use the script tab of the Xima® Formcycle Designer, or upload a Javascript file on the form's file menu. For example, to change the money validator to accept periods instead of commas as the decimal separator, you can edit the validator as follows.

XM_FORM_VRULES.money = /^-{0,1}([0]{1}|[1-9]{1}[0-9]*)[.]{1}[0-9]{2}$/

It is also possible to change the error message that will be displayed, either by modifying the error message directly or by editing the error messages template. Error messages are contained in the Javascript object window.XM_FORM_VRULES. To change the error message for the money validator directly via Javascript, use the following code:

XM_FORM_I18N.money = 'Not a valid amount of money. Please use a period as separator (eg. 100.00)';

You can also add custom entries to the object XM_FORM_VRULES and XM_FORM_I18N. The name of the entry is the name of the validator. To use this validator to validate an input field, add the HTML attribute vdt to the input field and set its value to the name of the validator.

For example, if you want to add a validator for numbers with at most 5 digits and 2 decimal digits, add the following Javascript code.

  XM_FORM_VRULES.number_5_2 = new RegExp(/^([0]{1}|[1-9]{1}[0-9]{0,5})[,]{1}[0-9]{2}$/);
  XM_FORM_I18N.number_5_2 = "Please enter a number with at most 5 digits and 2 decimal digits.";

Finally, add the HTML attribute vdt to the input field and set its value to number_5_2.

Creating custom validators

errorFunc()

You can create your own validators by using the Xima® Formcycle specific jQuery function errorFunc().

function getErrorMsg(){
   var el = $(this),
   var msg = el.attr('name') + ' is not valid';
   return (el.val() == 'a') ? msg : '';
}
$('[name=tf1]').errorFunc(getErrorMsg); // Entering the letter "a" into the text field tf1 will show an error.

error()

You can also mark a form field as invalid by using the function error(message).

$('[name=tf1]').error('Invalid input.'); //Add the error message "invalid input" to the text field tf1.
$('[name=tf1]').error(''); // Removes any error messages from the text field tf1.

Internationalisierung (i18n)

This example shows how to change the error message for the currency data type.

You can customize the error messages in two ways:

To change an error message via JavaScript, such as for the currency, use the following script:

XM_FORM_I18N.money = "Ich bin eine geänderte Fehlermeldung";
Created by awa on 03.05.2019, 09:35
Translated into en by awa on 03.05.2019, 09:35
Copyright 2000-2025