addInvalidField (fieldName, fieldError)
JavaScript API Reference/Ab.form.Form object
addInvalidField (fieldName, fieldError)
Mark a specified field as invalid by displaying an inline error message. This function is typically called from the form's custom
beforeSave
event handler. The
beforeSave
event handler should return
false
if an invalid field has been added in order to terminate the save process. The event
handler may call the
addInvalidField()
function more than once to mark multiple fields.
Parameters:
-
fieldName
(String): the full name of the invalid field; -
fieldError
(String): error message to be displayed.
Example:
If the conditions for a valid Priority value are not met, mark the field as invalid. Add the localized error message
(defined as a
<message>
element in the AXVW) to the field. Return
false
to terminate the save process:
var priority = this.optionsForm.getFieldValue('wr.priority');
if (priority > 75) {
this.optionsForm.addInvalidField('wr.priority', getMessage('priority_too_high'));
return false;
}