- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 04:55 AM
Hi,
I want to add a simple validation to a custom integer field. I can see how the validation scripts work, and that there is a script to do exactly what I need, however, I cannot see how I can link the validation script to the custom field.
The field is called u_minutes and is within the incident table.
Any guidance that could be provided would be greatly appreciated.
Thanks in advance,
Dan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 05:36 AM
Hmm.. I never thought about it, but it doesn't seem to be the validation script that turns it into a 0, it must be something else. But is it possible that the value never should be 0? then you should able to do a onChange for that field like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 0){
g_form.showErrorBox('u_nummer','Please fill in a correct number');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 05:36 AM
Hmm.. I never thought about it, but it doesn't seem to be the validation script that turns it into a 0, it must be something else. But is it possible that the value never should be 0? then you should able to do a onChange for that field like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 0){
g_form.showErrorBox('u_nummer','Please fill in a correct number');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 05:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 06:06 AM
Thanks all - I actually used this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 0){
alert('Please enter a numerical value in the "Minutes" field');
g_form.setValue('u_minutes','');
}
}
This will send an alert and reset the field value back to empty otherwise they are able to submit the form as it was defaulting to a "0"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 06:12 AM
Yes just was about to tell as showErrorBox proposed by Goran would only give a UI level error message but allows the user to submit the form. Anyways you just modified to what it can be
Thanks, Siva