How to validate a whether a cell has exactly 10 digits in spreadjs?

292 views Asked by At

I have a spreadsheet created in spreadjs and I wanted to limit one of the cells to have a number that is exactly 10 digits. I want to allow the user to pad it with 0's in the beginning. If I create a textLengthValidator, it allows any text, if i create a number validator, it allows less than 10 digits to be entered.

  var dv2 = $.wijmo.wijspread.DefaultDataValidator.createTextLengthValidator($.wijmo.wijspread.ComparisonOperator.EqualsTo, 10, 10);
            sheet.getColumn(6).dataValidator(dv2);
var dv3 = $.wijmo.wijspread.DefaultDataValidator.createNumberValidator($.wijmo.wijspread.ComparisonOperator.Between, 0000000000, 9999999999, true);
                sheet.getColumn(6).dataValidator(dv3)

Any thoughts on how to proceed with this?

1

There are 1 answers

0
rrgirish On BEST ANSWER

This worked for me:

var dv3 = $.wijmo.wijspread.DefaultDataValidator.createFormulaValidator("=AND(COUNTIF(G:G,G1)=1,LEN(G1)=10,ISNUMBER(VALUE(G1)))");