You can use data validation to control the type of data and values that users are allowed to enter in a cell. This can be useful if you only want to allow correct values in a cell based on your data. SpreadJS supports data validation. Create validators to validate the user data. You can display a list of valid values for the user and display an invalid data image if the user types invalid data. Use the highlightInvalidData method to specify a red ellipse as an invalid data image. You can use any of several types of validator methods to create the validation criteria.
- createDateValidator
- createFormulaValidator
- createFormulaListValidator
- createListValidator
- createNumberValidator
- createTextLengthValidator
The ValidationError event occurs when the applied cell value is invalid. You can also use the isValid method to check that a cell value is valid based on the validation. This example creates a list of valid values for the Category column. List Data JavaScript
This example uses a text validator, displays an input tip, and displays an invalid data image if the incorrect value is entered. Text Validator JavaScript
This example uses a number validator, displays an input tip, and displays an invalid data image if the incorrect value is entered. Number Validator JavaScript
This example creates a date validator. Date Validator JavaScript
This example creates a formula validator. Formula Validator JavaScript
This example uses the isValid method. JavaScript
This example uses the ValidationError event. JavaScript