Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.)

...

  1. Visit the Field List within the module for which the form field is to be made valid/invalid.

  2. To setup a validation message, the following JavaScript must be executed in the form field on Init/Blur.
    fieldScope.addValidationMessage("MyValidationName", "My test validation");

  3. The method 'addValidationMessage' on the fieldScope takes a key for the validation and a corresponding message.

  4. Review the form to ensure the Message and field reflect the validation applied through the Custom JavaScript.

...

Tip: It’s useful to use these within Conditional Statements to apply Valid/Invalid message accordingly.

...

Info

Marking a field as invalid/valid

To mark a field as valid / invalid use the following JavaScript code.

//to set the field to be invalid.

fieldScope.setValidity('MyValidationName', false)

//to set the field to be valid.
fieldScope.setValidity('MyValidationName', true)

Info

Marking another field on the form as invalid/valid

To mark a field other than the one referenced by the fieldScope, use the following JavaScript code.

//to mark another field invalid.

$scope.setFieldValidity(<display name of the other field>, 'MyValidationName', false);

//to mark another field valid.

$scope.setFieldValidity(<display name of the other field>, 'MyValidationName', true);

Page Properties
hiddentrue

Related issues