A field can be marked valid or invalid via Custom JavaScript. Setting a field invalid will prevent the form from being submitted. An invalid message can be setup to show below the field when the field is marked invalid.
(Note: A field has to be dirty for the validation message to show.)
...
Visit the Field List within the module for which the form field is to be made valid/invalid.
To setup a validation message, the following JavaScript must be executed in the form field on Init/Blur.
fieldScope.addValidationMessage("MyValidationName", "My test validation");The method 'addValidationMessage' on the fieldScope takes a key for the validation and a corresponding message.
Review the form to ensure the Message and field reflect the validation applied through the Custom JavaScript.
...