GibboK GibboK - 1 month ago 11
Javascript Question

dijit ValidationTextBox how to add minlength and maxlength

I would like to know how (with simple working example) to add

maxlength
and
minlength
to input tag generated by

dijit/form/ValidationTextBox


Example of desired output:

<input maxlength="10" minlength="2" class="dijitReset dijitInputInner" data-dojo-attach-point="textbox,focusNode" autocomplete="off" name="title" type="text" tabindex="0" id="Image-1-title-LabelValidationTextBox" aria-required="undefined" value="Title text for image Image-1" aria-invalid="false">

Answer

try this example with regex constraint

<input type="text" value="someTestString" required="true"
data-dojo-type="dijit/form/ValidationTextBox"
data-dojo-props="regExp: '[a-zA-Z0-9$%!_]{2,10}', invalidMessage: 'The value must be at least 2 character and maximum 10'" />