Validation of a spinner field in form is not working as expected. In catalog 17.1.0.16, the validation function only works correctly when the field value is changed manually in the text box, and does not work when the attached arrows of the spinner field are used or the form is submitted.
The function is configured in the onValidate attribute of the field with the call ca_fd.js.validate(_val), and the function code is written in the script dialog.
{
validate:function(value){
console.log('Validate field '+value);
var ip_free = parseInt(ca_fdGetTextFieldValue(formId,'ip_free'),10);
var ip_add = parseInt(value,10);
if(ip_add > ip_free){
return 'Validation failed';
}
else{
return null;
}
}
}
Is it a bug or has the field changed its behavior?
Good Morning Vinicius.
Could this be of help for you?
https://docops.ca.com/ca-process-automation/4-2-2/en/reference/form-reference/form-element-events
onValidate
Occurs when the associated code verifies a field value against business rules before one of the following actions occurs:
- The field value is stored in the data buffer.
- The field value is written to the database.
For example, the user tabs to or clicks a Serial Number field that must start with the letters SN and contain 10 numeric digits.
Before the user can tab to the next field or click away from the field,
the onValidate event and its associated code verify the data.
You can alert the user if the serial number does not meet validation rules so they can adjust their entry.
You can use onValidate for custom validation of the field input.
For example, to ensure that a field input is at least three characters in length,
you can write a custom function in the Script dialog:
validateValue:function(_val) {
if(_val.length < 3) {
return "Please enter more than 3 characters for this field";
} else {
return null;
}
In the Form Designer, include the onValidate attribute value for the text field on which to run the validation.
For example:
ca_fd.js.validateValue(_val)
The custom function replaces the required parameter _val with the correct field value when the script runs.
If the validation script returns a null value, the field input passes validation.
Otherwise, the field input fails validation and the script returns an error
(for example, "Enter more than 3 characters for this field").
Kind regards, Louis van Amelsfort.