Contraints on dijit.form.ValidationTextBox

98 views Asked by At

How to specify length constraint of min and max digits on dijit.form.ValidationTextBox programmatically ?

Thanks

1

There are 1 answers

0
Tariq On

I recommend you to use the 'pattern' option which used regex to manage min and max:

eb = new ValidationTextBox({
    value: 2,
    pattern: '[\\w]{2,4}'
});

I will explain the pattern: [\\w]{2,4}.
\w: accept letters only.
{2,4}: define min and max letters that are allowed. min is 2 and max is 4.
If you want to unlimit the max, leave it empty like this: {2,}.
You can add \\d AS numbers only or combine then with letters like this: \\w\\d