ui.igValidator

ui.igValidator_image

Code Sample

 
    <!DOCTYPE html>
    <html>
    <head>
         <!--Ignite UI Required Combined CSS Files-->
        <link href="css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
        <link href="css/themes/infragistics/infragistics.ui.popover.css" rel="stylesheet" />
        <link href="css/themes/infragistics/infragistics.ui.notifier.css" rel="stylesheet" />
        <link href="css/themes/infragistics/infragistics.ui.editors.css" rel="stylesheet" />
        <link href="css/themes/infragistics/infragistics.ui.shared.css" rel="stylesheet" />
        <link href="css/structure/infragistics.css" rel="stylesheet" />

        <script src="js/modernizr-latest.js"></script>
        <script src="js/jquery.js"></script>
        <script src="js/jquery-ui.js"></script>

         <!--Ignite UI Required Combined JavaScript Files--> 
        <script src="js/infragistics.core.js"></script>
        <script src="js/infragistics.lob.js"></script>

        <script type="text/javascript">
   
            $(document).ready(function () {

                $('#validator').igTextEditor({
                    placeHolder: "User name"
                });

                  $('#validator').igValidator({
                    notificationOptions: {
                        direction: "right",
                        showIcon: "true",
                        mode:"popover"
                    },
                    required:true
                  });
            });


        </script>
    </head>
    <body>
        <input id="validator"/>
    </body>
    </html>
    

Related Samples

Related Topics

Dependencies

jquery-1.9.1.js
jquery.ui.core.js
jquery.ui.widget.js
infragistics.util.js
infragistics.ui.popover.js
infragistics.ui.notifier.js

Inherits

  • custom

    Type:
    enumeration
    Default:
    null

    Gets or sets a custom function to perform validation. Use 'this' to reference the calling validator and the value and optional field settings arguement to determine and return the state of the field.

    Members

    • function
    • Type:function
    • The function to call.
    • string
    • Type:string
    • Function name, must be in global namespace (window["name"]).
    • object
    • Type:object
    • A configuration object with method property being the function and optional error message.

    Code Sample

                //Initialize
                $('.selector').igValidator({
                  custom: function(value, fieldOptions){
                          return false;
                  }
                });
    
                //Get
                var custom = $(".selector").igValidator("option", "custom");
     
                //Set
                var custom = { 
                      method: function (value, fieldOptions) {
                          return false;
                      }, 
                      errorMessage: "This field is required."
                  };
    
                $(".selector").igValidator("option", "custom", custom);
          
  • date

    Type:
    enumeration
    Default:
    false

    Gets or sets option to validate if value is a date. This can help guide the valueRange validation. Note: Dependat on JavaScript Date parsing which will accept a wide range of values.

    Members

    • boolean
    • Type:bool
    • A boolean value indicating if the field should be a valid JavaScript Date or can be parsed as one.
    • object
    • Type:object
    • A configuration object with optional error message (e.g. date: { errorMessage: "Enter a valid number"} ).

    Code Sample

     
                //Initialize
                $('.selector').igValidator({
                  date: true
                });
    
                //Get
                var date = $(".selector").igValidator("option", "date");
     
                //Set
                $(".selector").igValidator("option", "date", true);
          
  • email

    Type:
    enumeration
    Default:
    false

    Gets or sets option to validate if value is an email. Note: Dependat on JavaScript Date parsing which will accept a wide range of values.

    Members

    • boolean
    • Type:bool
    • A boolean value indicating if the field should be an email.
    • object
    • Type:object
    • A configuration object with optional error message (e.g. email: { errorMessage: "Enter a valid email"} ).

    Code Sample

     
                //Initialize
                $('.selector').igValidator({
                  email: true
                });
    
                //Get
                var email = $(".selector").igValidator("option", "email");
     
                //Set
                $(".selector").igValidator("option", "email", true);
          
  • equalTo

    Type:
    enumeration
    Default:
    null

    Requires the value in this field to be the same as another input element or editor control.

    Members

    • string
    • Type:string
    • A valid jQuery selector for the target element.
    • object
    • Type:object
    • A reference to the jQuery object for the target or an object with selector property and custom errorMessage.

    Code Sample

     
                //Initialize
                $('.selector').igValidator({
                  equalTo: "#field1"
                });
    
                //Get
                var equalTo = $(".selector").igValidator("option", "equalTo");
     
                //Set
                $(".selector").igValidator("option", "equalTo", "#field1");
          
  • errorMessage

    Type:
    string
    Default:
    null

    Gets or sets text for error-message to be used if none is set for the particular rule. Overrides default rule-specific error messages.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
            errorMessage: 'This field is required!'
          });
    
          //Get
          var errorMessage = $(".selector").igValidator("option", "errorMessage");
     
          //Set
          $(".selector").igValidator("option", "errorMessage", 'This field is required!');
          
  • fields

    Type:
    array
    Default:
    []
    Elements Type:
    object

    List of field items describing each field with validation options and a required selector. Fields can contain any of the validation rules and triggers but not other fields or event handlers.
    Accepted options are also inherited from the global control configuration if not set.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              fields: [{
                  selector: "#input1",
                  required: true,
                  number: true,
                  onblur: false
                },
                {
                  selector: "#input2",
                  lengthRange: {
                    min: 2,
                    max: 10
                  },
                  onchange: true
                }
              ]
          });
    
          //Get
          var fields = $(".selector").igValidator("option", "fields");
          
    • selector

      Type:
      enumeration
      Default:
      null

      The DOM element (input or control target) to be validated. This field setting is required.

      Members

      • string
      • Type:string
      • A valid jQuery selector for the element.
      • object
      • Type:object
      • A reference to a jQuery object.

      Code Sample

       
                      //Initialize
            $('.selector').igValidator({
                fields: [{
                    selector: "#input1"
                  },
                  {
                    selector: "#input2"
                  }
                ]
            });
                
  • lengthRange

    Type:
    enumeration
    Default:
    null

    Gets or sets minimum and maximum length of text or number of selected items. Null or 0 values are ignored.

    Members

    • array
    • Type:array
    • An array of two numbers, where the first value is the minimum and the second is the maximum. (e.g. lengthRange: [ 1, 10] ).
    • object
    • Type:object
    • A configuration object with optional error message. Message strings can contain format items for min and max respecitively (e.g. lengthRange: { min: 6, max: 20, errorMessage: "Password must be at least {0} long and no more than {1}." } ).

    Code Sample

     
            //Initialize
            $('.selector').igValidator({
              lengthRange: [2, 6]
            });
    
            //Get
            var lengthRange = $(".selector").igValidator("option", "lengthRange");
     
            //Set
            $(".selector").igValidator("option", "lengthRange", [2, 6]);
          
  • messageTarget

    Type:
    domelement
    Default:
    null

    Gets or sets custom jQuery element, which innerHTML will be used to show validation messages. That can be SPAN, LABEL or DIV.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
            messageTarget: "#field1"
          });
    
          //Get
          var messageTarget = $(".selector").igValidator("option", "messageTarget");
     
          //Set
          $(".selector").igValidator("option", "messageTarget", "#field1"); 
          
  • notificationOptions

    Type:
    object
    Default:
    null

    Options for the igNotifier used to show error messages.

    Code Sample

     
                //Initialize
                $('.selector').igValidator({
                  notificationOptions: {
                      direction: "right",
                      showIcon: "true",
                      mode:"popover", 
                      messages: {
                          error: "This field is required!"
                      }
                  }
                });
    
                //Get
                var notificationOptions = $(".selector").igValidator("option", "notificationOptions");
     
                //Set
                var notificationOptions = {
                      direction: "right",
                      showIcon: "true",
                      mode:"popover", 
                      messages: {
                          error: "This field is required!"
                      };
    
                $(".selector").igValidator("option", "notificationOptions", notificationOptions);
          
  • number

    Type:
    enumeration
    Default:
    false

    Gets or sets option to validate if value is a number. Default separators for decimals and thousands are '.' and ',' respectively.

    Members

    • boolean
    • Type:bool
    • A boolean value indicating if the field should be a number.
    • object
    • Type:object
    • A configuration object with errorMessage, decimalSeparator and thousandsSeparator. Those properties are all optional.

    Code Sample

     
                //Initialize
                $('.selector').igValidator({
                  number: true
                });
    
                //Get
                var number = $(".selector").igValidator("option", "number");
     
                //Set
                $(".selector").igValidator("option", "number", true);
          
  • onblur

    Type:
    bool
    Default:
    true

    Gets or sets triggering validation when editor lost focus.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              onblur: true
          });
    
          //Get
          var onblur = $(".selector").igValidator("option", "onblur");
     
          //Set
          $(".selector").igValidator("option", "onblur", true); 
          
  • onchange

    Type:
    bool
    Default:
    false

    Gets or sets triggering validation when value in editor was changed.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              onchange: true
          });
    
          //Get
          var onchange = $(".selector").igValidator("option", "onchange");
     
          //Set
          $(".selector").igValidator("option", "onchange", true); 
          
  • onsubmit

    Type:
    bool
    Default:
    true

    Gets or sets triggering validation when form gets onsubmit event.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              onsubmit: true
          });
    
          //Get
          var onsubmit = $(".selector").igValidator("option", "onsubmit");
     
          //Set
          $(".selector").igValidator("option", "onsubmit", true); 
          
  • optionalIndication

    Type:
    bool
    Default:
    false

    Option to show a label indication next to optional fields.
    Note: Indicators are not supported on grouped controls such as checkbox or radio button sets and the igRating control.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              optionalIndication: true
          });
    
          //Get
          var optionalIndication = $(".selector").igValidator("option", "optionalIndication");
     
          //Set
          $(".selector").igValidator("option", "optionalIndication", true); 
          
  • pattern

    Type:
    enumeration
    Default:
    null

    Gets or sets regular expression which is used to validate value in text editor.

    Members

    • string
    • Type:string
    • A string containing regular expression.
    • object
    • Type:object
    • A RegExp object or an object with expression and errorMessage properties.

    Code Sample

     
          //Initialize
          $(".selector").igValidator({
              pattern : "^\\d*\\.{0,1}\\d+$"
          });
     
          //Get
          var pattern = $(".selector").igValidator("option", "pattern");
     
          //Set
          $(".selector").igValidator("option", "pattern", "^\\d*\\.{0,1}\\d+$");
          
  • required

    Type:
    enumeration
    Default:
    false

    Gets or sets option to validate if value was entered (not empty text, selected item, etc.).

    Members

    • boolean
    • Type:bool
    • A boolean value indicating if the field is required.
    • object
    • Type:object
    • A configuration object with optional error message (e.g. required: { errorMessage: "Error!"} ).

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              required: true
          });
    
          //Get
          var required = $(".selector").igValidator("option", "required");
     
          //Set
          $(".selector").igValidator("option", "required", true); 
          
  • requiredIndication

    Type:
    bool
    Default:
    false

    Option to show an asterisks indication next to required fields.
    Note: Indicators are not supported on grouped controls such as checkbox or radio button sets and the igRating control.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              requiredIndication: true
          });
    
          //Get
          var requiredIndication = $(".selector").igValidator("option", "requiredIndication");
     
          //Set
          $(".selector").igValidator("option", "requiredIndication", true); 
          
  • successMessage

    Type:
    string
    Default:
    null

    Gets or sets text for success message. Note there is no default, so setting this message will enable showing success indications.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              successMessage: "Well done!"
          });
    
          //Get
          var successMessage = $(".selector").igValidator("option", "successMessage");
     
          //Set
          $(".selector").igValidator("option", "successMessage", "Well done!");
          
  • threshold

    Type:
    number
    Default:
    -1

    Gets or sets validation minimum input length. Validation won't be triggered for input before that value is reached on change and blur.
    Note: This will have no effect on required fields on form submit.

    Code Sample

     
          //Initialize
          $('.selector').igValidator({
              threshold: 1
          });
    
          //Get
          var threshold = $(".selector").igValidator("option", "threshold");
     
          //Set
          $(".selector").igValidator("option", "threshold", 1); 
          
  • valueRange

    Type:
    enumeration
    Default:
    null

    Gets or sets minimum and maximum values. Null values are ignored.

    Members

    • array
    • Type:array
    • An array of two numbers or dates, where the first is the minimum and the second is the maximum. (e.g. valueRange: [ 1, 10] ).
    • object
    • Type:object
    • A configuration object with optional error message. Message strings can contain format items for min and max respecitively (e.g. lengthRange: { min: 6, max: 20, errorMessage: "Value must be between {0} and {1}." } ).

    Code Sample

     
                //Initialize
                $('.selector').igValidator({
                    valueRange: [2, 6]
    
                //Get
                var valueRange = $(".selector").igValidator("option", "valueRange");
     
                //Set
                var range = [2, 6];
                $(".selector").igValidator("option", "valueRange", range); 
          

For more information on how to interact with the Ignite UI controls' events, refer to
Using Events in Ignite UI.

Note: Calling API methods programmatically does not raise events related to their operation unless specifically stated otherwise by the corresponding API documentation; those events are only raised by their respective user interaction.

Show Details
  • error

    Cancellable:
    false

    Event raised for invalid field after value was validated but before any action takes effect.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.value to get current value in target.
    Use ui.valid to determine the outcome of the validation.
    Use ui.message to get text of message.
    ui.rule is populated with the name of the rule that failed validation, if any.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorerror", function (evt, ui) {
     
    				//get reference to the igValidator widget
    				ui.owner;
    				//get current value in target
    				ui.value;
    				//determine the outcome of the validation
    				ui.valid;
    				//get name of the rule that failed validation
    				ui.rule;
    				//gets text of message
    				ui.message;
    				//get the options of the specific field in the collection
    				ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    error: function (evt, ui) {
                    ...
                    }
                });
          
  • errorHidden

    Cancellable:
    false

    Event which is raised after error message was hidden.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

          $(document).delegate(".selector", "igvalidatorerrorhidden", function (evt, ui) {
     
     			//get reference to the igValidator widget
    			ui.owner;
     			//gets text of message
     			ui.message;
    			//get reference to the target of the message
    			ui.target;
    			//get the options of the specific field in the collection
    			 ui.fieldOptions;
     
          });
     
          //Initialize
          $(".selector").igValidator({
              errorHidden: function (evt, ui) {
              ...
              }
          });
          
  • errorHiding

    Cancellable:
    true

    Event which is raised before error message is hidden.
    Return false in order to keep error message displayed.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
          $(document).delegate(".selector", "igvalidatorerrorhiding", function (evt, ui) {
     
     			//get reference to the igValidator widget
    			ui.owner;
     			//gets text of message
     			ui.message;
    			//get reference to the target of the message
    			ui.target;
    			//get the options of the specific field in the collection
    			 ui.fieldOptions;
     
          });
     
          //Initialize
          $(".selector").igValidator({
              errorHiding: function (evt, ui) {.
              ...
              }
          });
          
  • errorShowing

    Cancellable:
    true

    Event which is raised before error message is displayed.
    Return false in order to prevent error message display.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
          $(document).delegate(".selector", "igvalidatorerrorshowing", function (evt, ui) {
    						
     			//get reference to the igValidator widget
    			ui.owner;
     			//gets text of message
     			ui.message;
    			//get reference to the target of the message
    			ui.target;
    			//get the options of the specific field in the collection
    			 ui.fieldOptions;
     
          });
     
          //Initialize
          $(".selector").igValidator({
              errorShowing: function (evt, ui) {
              ...
              }
          });
          
  • errorShown

    Cancellable:
    false

    Event which is raised after error message was displayed.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
          $(document).delegate(".selector", "igvalidatorerrorshown", function (evt, ui) {
    
     			//get reference to the igValidator widget
    			ui.owner;
     			//gets text of message
     			ui.message;
    			//get reference to the target of the message
    			ui.target;
    			//get the options of the specific field in the collection
    			 ui.fieldOptions;
     
          });
     
          //Initialize
          $(".selector").igValidator({
              errorShown: function (evt, ui) {
              ...
              }
          });
          
  • formError

    Cancellable:
    false

    Event triggered on Validator instance level after failed validation on form submit event
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.target to get reference of the event target form.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorformerror", function (evt, ui) {
     
                    //get reference to the igValidator widget
                    ui.owner;
                    //get reference of the event target form
                    ui.target
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    formError: function (evt, ui) {
                    ...
                    }
                });
          
  • formSuccess

    Cancellable:
    false

    Event triggered on Validator instance level after successful validation on form submit event
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.target to get reference of the event target form.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorformsuccess", function (evt, ui) {
     
                    //get reference to the igValidator widget
                    ui.owner;
                    //get reference of the event target form
                    ui.target;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    formSuccess: function (evt, ui) {
                    ...
                    }
                });
          
  • formValidated

    Cancellable:
    false

    Event triggered on Validator instance level after validation on form submit event
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.target to get reference of the event target form.
    Use ui.valid to determine the outcome of the validation.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorformvalidated", function (evt, ui) {
     
                    //get reference to the igValidator widget
                    ui.owner;
                    //get reference of the event target form
                    ui.target;
                    //determine the outcome of the validation
                    ui.valid;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    formValidated: function (evt, ui) {
                    ...
                    }
                });
          
  • formValidating

    Cancellable:
    true

    Event triggered on Validator instance level before handling a form submit event.
    Return false to cancel to skip validating and potentially allow the submit if no other other validators return erros.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.target to get reference of the event target form.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorformvalidating", function (evt, ui) {
     
                    //get reference to the igValidator widget
                    ui.owner;
                    //get reference of the event target form
                    ui.target;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    formValidating: function (evt, ui) {
                    ...
                    }
                });
          
  • success

    Cancellable:
    false

    Event raised for valid field after value was validated but before any action takes effect.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.value to get current value in target.
    Use ui.valid to determine the outcome of the validation.
    Use ui.message to get text of message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

                $(document).delegate(".selector", "igvalidatorsuccess", function (evt, ui) {
    
    				//get reference to the igValidator widget
    				ui.owner;
    				//get current value in target
    				ui.value;
    				//gets text of message, if any
    				ui.message;
    				//get the options of the specific field in the collection
    				ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    success: function (evt, ui) {
                    ...
                    }
                });
          
  • successHidden

    Cancellable:
    false

    Event which is raised after success message was hidden.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorsuccesshidden", function (evt, ui) {
     
     			//get reference to the igValidator widget
    			ui.owner;
     			//gets text of message
     			ui.message;
    			//get reference to the target of the message
    			ui.target;
    			//get the options of the specific field in the collection
    			 ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    successHidden: function (evt, ui) {
                    ...
                    }
                });
          
  • successHiding

    Cancellable:
    true

    Event which is raised before success message is hidden.
    Return false in order to keep success message displayed.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorsuccesshiding", function (evt, ui) {
     
     			//get reference to the igValidator widget
    			ui.owner;
     			//gets text of message
     			ui.message;
    			//get reference to the target of the message
    			ui.target;
    			//get the options of the specific field in the collection
    			 ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    successHiding: function (evt, ui) {
                    ...
                    }
                });
          
  • successShowing

    Cancellable:
    true

    Event which is raised before success message is displayed.
    Return false in order to prevent success message display.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorsuccessshowing", function (evt, ui) {
     
    				//get reference to the igValidator widget
    				ui.owner;     	
    				//gets text of message
    				ui.message;
    				//get reference to the target of the message
    				ui.target;
    				//get the options of the specific field in the collection
    				ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    successShowing: function (evt, ui) {
                    ...
                    }
                });
          
  • successShown

    Cancellable:
    false

    Event which is raised after success message was displayed.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.message to get text of message.
    Use ui.target to get reference to the target of the message.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorsuccessshown", function (evt, ui) {
     
    				//get reference to the igValidator widget
    				ui.owner;     	
    				//gets text of message
    				ui.message;
    				//get reference to the target of the message
    				ui.target;
    				//get the options of the specific field in the collection
    				ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    successShown: function (evt, ui) {
                    ...
                    }
                });
          
  • validated

    Cancellable:
    false

    Event which is raised after value was validated but before any action takes effect.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.value to get current value in target.
    Use ui.valid to determine the outcome of the validation.
    Use ui.message to get text of message.
    ui.rule is populated with the name of the rule that failed validation, if any.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorvalidated", function (evt, ui) {
     
                  //get reference to the igValidator widget
                  ui.owner;
                  //get current value in target
                  ui.value;
                  //determine the outcome of the validation
                  ui.valid;
                  //gets text of message if available
                  ui.message;
                  //get name of the rule that failed validation, if any.
                  ui.rule;
                  //get the options of the specific field in the collection
                  ui.fieldOptions;
     
              });
     
              //Initialize
              $(".selector").igValidator({
                  validated: function (evt, ui) {
                  ...
                  }
              });
          
  • validating

    Cancellable:
    true

    Event which is raised on validation before default validation logic is applied.
    Return false in order to cancel the event and consider the field valid.
    Function takes arguments evt and ui.
    Use ui.owner to get reference to the igValidator widget.
    Use ui.value to get current value in target.
    ui.fieldOptions is populated with options for the specific field in the collection or null.

    Code Sample

     
                $(document).delegate(".selector", "igvalidatorvalidating", function (evt, ui) {
     
                    //get reference to the igValidator widget
                    ui.owner;
                    //get current value in target
                    ui.value ;
                    //get the options of the specific field in the collection
                    ui.fieldOptions;
     
                });
     
                //Initialize
                $(".selector").igValidator({
                    validating: function (evt, ui) {
                    ...
                    }
                });
          
  • addField

    .igValidator( "addField", field:object );

    Adds an new input to the fields collection and initializes it with the validator. Note: Additional fields are only accepted if the validator has been created with the collection.

    • field
    • Type:object
    • An object with the field selector and options.

    Code Sample

     
              var field = {
                selector: "#input1",
                required: true,
                number: true,
                onblur: false
              };
          $(".selector").igValidator("addField",field);
          
          
  • destroy

    .igValidator( "destroy" );

    Destroys the validator widget.

    Code Sample

     $(".selector").igValidator("destroy"); 
  • getErrorMessages

    .igValidator( "getErrorMessages", [field:object] );
    Return Type:
    array
    Return Type Description:
    An array of all current error messages.

    Gets all current error messages for invalid field(s). Note that this method does not valdiate and states and messages are only updated on validation, so
    this can be used on formValidated event or after validate/isValid method calls.

    • field
    • Type:object
    • Optional
    • Selector or zero-based index for a single field to get error message for.

    Code Sample

     var getErrorMessages = $(".selector").igValidator("getErrorMessages","#field1"); 
  • hide

    .igValidator( "hide", [field:object] );

    Hide any possible message (either messageTarget or igNotifier).
    Note: When the validator has a fields colleciton, not passing a field will hide messages on all fields.

    • field
    • Type:object
    • Optional
    • Optional field to hide message for.

    Code Sample

     $(".selector").igValidator("hide"); 
  • isMessageDisplayed

    .igValidator( "isMessageDisplayed", [field:object] );
    Return Type:
    bool
    Return Type Description:
    True if there is a currently visible message.

    Check for currently displayed message(s). Takes an optional field.
    Note: When the validator has a fields colleciton, not passing a field will return a cumulative true even if just one field has visible message.

    • field
    • Type:object
    • Optional
    • Selector or zero-based index for a single field to get error message for.

    Code Sample

     var isMessageDisplayed = $(".selector").igValidator("isMessageDisplayed","#field1"); 
  • isValid

    .igValidator( "isValid", [field:object] );
    Return Type:
    bool
    Return Type Description:
    True if the field(s) passed all checks.

    Trigger validation but do not display error messages.

    • field
    • Type:object
    • Optional
    • Optional field object to check (skips other fields, only works with fields collection).

    Code Sample

     var isValid = $(".selector").igValidator("isValid"); 
  • notifier

    .igValidator( "notifier", [field:object] );
    Return Type:
    object
    Return Type Description:
    Reference to igNotifier or null on incorect field.

    Gets the notifier for the igValidator or for a single filed.

    • field
    • Type:object
    • Optional
    • Optional field object, its selector or zero-based index to get notifier for.

    Code Sample

     var notifier = $(".selector").igValidator("notifier"); 
  • removeField

    .igValidator( "removeField", field:object );

    Removes an input from the fields collection.

    • field
    • Type:object
    • The field object to remove, its zero-based index or selector.

    Code Sample

     $(".selector").igValidator("removeField","#input1"); 
  • updateField

    .igValidator( "updateField", field:object, [fieldOptions:object] );

    Updates a field in the validator collection. Used to reinitialize field in case a control has been created after the validator or to pass in new options.

    • field
    • Type:object
    • The field object to update, its zero-based index or selector.
    • fieldOptions
    • Type:object
    • Optional
    • New options to apply to the fields.

    Code Sample

     
              var newOptions = {
                required: true,
                number: true,
                onblur: false
              };
          $(".selector").igValidator("updateField","#input1", newOptions);
          
  • validate

    .igValidator( "validate", [field:object] );
    Return Type:
    bool
    Return Type Description:
    True if the field(s) passed all checks.

    Trigger validation and show errors for invalid fields.

    • field
    • Type:object
    • Optional
    • Optional field object to check. Only has effect with fields collection and skips other fields.

    Code Sample

     var validate = $(".selector").igValidator("validate"); 
  • ui-igvalidator-optional-indication

    Class applied to the indication span next to optional fields .
  • ui-igvalidator-required-indication

    Class applied to the asterisks indication span next to required fields .
  • ui-igvalidator-target

    Class applied to the target element with validation. Has no visual effect.

Copyright © 1996 - 2024 Infragistics, Inc. All rights reserved.

#