This simple validation example validates that field value includes a balloon 🎈
Form configuration example:
{
"Groups": [
{
"Name": "Group 1",
"Fields": [
{
"InternalName": "my_field",
"Validation": {
"ValidationFunction": "validateMyField"
}
}
]
}
],
"Resources": [
{
"LCID": "1029",
"validations": {
"shouldIncludeABalloon": "Pole by mělo obsahovat balónek 🎈"
}
},
{
"LCID": "1033",
"validations": {
"shouldIncludeABalloon": "Field should include a baloon 🎈"
}
}
]
}
Custom script example:
function validateMyField(value) {
const { translation } = tisa.utils;
if (!value.includes("🎈")) {
return translation("validations.shouldIncludeABalloon");
}
}
This validation validates that the field's date is within the range of ±7 days from today.
Form configuration example:
{
"Groups": [
{
"Name": "Group 1",
"Fields": [
{
"InternalName": "my_field",
"Validation": {
"ValidationFunction": "validateDateRage"
}
}
]
}
],
"Resources": [
{
"LCID": "1029",
"validations": {
"dateNotWithinRange": "Datum by mÄ›lo být v rozmezà ±7 dnÃ."
}
},
{
"LCID": "1033",
"validations": {
"dateNotWithinRange": "Date should be within the range of ±7 days."
}
}
]
}
Custom script example:
function validateDateRage(value) {
const { translation } = tisa;
const date = new Date(value);
const today = new Date();
const diffDays = (date - today) / (1000 * 60 * 60 * 24);
if (Math.abs(diffDays) >= 7) {
return translation("validations.dateNotWithinRange");
}
}