validation

a module for working with validation in cells

object validation;

Example

// adding a validation rule for the cell B3 on Sheet1
$$("ssheet").validation.add(
    3, 
    2, 
    {
      "type": "number",
      "integer": 1,
      "empty": 1,
      "condition": "greater",
      "value": "0",
      "inputMessage": "Rules:\n\n- integer greater than 0\n- include empty",
      "errorHandle": "info",
      "errorTitle": "Incorrect data!",
      "errorMessage": "Should be integer greater than 0!"
    }, 
    "Sheet1"
);

Details

The module has a set of API methods to work with validation:

  • add() - adds a validation rule to a cell. It takes the following parameters:
    • row (number) - the row ID
    • column (number) - the column ID
    • rule (object) - the validation rule. Has the following attributes:
      • type (string) - the validation criteria. It can be: "any" (a cell can have any content), "date", "number", "text", "textLength", "range" (to validate data among a cells range)
      • integer (boolean) - (for the number type only) true for accepting integer numbers only
      • ignoreEmpty (boolean) - true to ignore/ not ignore empty cells
      • condition (string) - a condition for validation
      • value (string/array) - a value or an array of two values (for the rules like "between/not between") that should be compared to the value of the specified cell
      • inputMessage (string) - a popup with the text specified in this property will be shown on selection of a cell
      • errorHandle (string) - the way of handling an error (in the corresponding confirm box):
        • "stop" - doesn't allow setting an incorrect value
        • "warning" - allows cancelling the set value
        • "information" - an box informing that the value is not valid
      • errorTitle (string) - the header of the confirm box with an error
      • errorMessage (string) - the text of the confirm box with an error
    • page (string) - optional, the name of the sheet. If not specified, applies the method to the current sheet
  • remove() - removes the applied validation rule from a cell. It takes the following parameters:
    • row (number) - the row ID
    • column (number) - the column ID
    • page (number) - the number of the page
  • get() - gets the validation rule applied to a cell. It takes the following parameters:
    • row (number) - the row ID
    • column (number) - the column ID
    • page (number) - the number of the page
  • highlight() - adds/removes highlighting to/from a cell with applied validation rules. It takes the following parameters:
    • state (boolean/"toggle") - true if highlighting for cells with validation rules is enabled
    • page - (string) optional, the name of the sheet. If not specified, applies the method to the current sheet
See also
Back to top