Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

PreValidate Form (on page load)

Ghislain B. edited this page May 30, 2015 · 16 revisions

By default Angular-Validation does not display any error at first, at least not until user start typing test in each of the Form Elements. You can change this behavior and display the error right from the beginning by simply change a global option.

####Directive Change the Angular-Validation default options

myApp.controller('Ctrl', function ($scope) {
  $scope.$validationOptions = { 
    debounce: 1500,                // set the debounce globally
    preValidateFormElements: true  // pre-validate all form elements, false by default
  }; 
});

####Service From the Service you can also change it the following way. P.S. This only works when all your elements have been defined by the Angular-Validation Service

myApp.controller('Ctrl', function ($scope) {
  // start by creating the service
  var myValidation = new validationService();

  // set property of preValidateFormElements (false by default)
  myValidation.setGlobalOptions({ debounce: 1500, scope: $scope, preValidateFormElements: true });
});
Clone this wiki locally