Page 1 of 1

How to specify the minimum length of text-boxes ?

Posted: Thu Jul 11, 2019 1:13 am
by mamad71
Hi guys,
I read the whole documentation about textbox fileds in dynaforms but i did not found any thing about how to set the minimum required length of textboxes.
Is there any way to set this constraint by extra options of textboxes in dynaforms or maybe some thing like a validate property or do i have to use javascript ?
Thank you in advance

Re: How to specify the minimum length of text-boxes ?

Posted: Thu Jul 11, 2019 11:04 pm
by amosbatto
In the validate property of the text field, you can use this regular expression to set a minimum of 10 characters:
^.{10,}$

And set this validation error message: Minimum of 10 characters

Re: How to specify the minimum length of text-boxes ?

Posted: Mon Jul 29, 2019 1:32 am
by mamad71
Thank you it works

Re: How to specify the minimum length of text-boxes ?

Posted: Wed Aug 28, 2019 9:17 am
by mamad71
Hi again
I have another question related to using validation rules for text boxes.
Is it possible to use a validation rule for a text box to only accept numeric values between two numbers ? for example only between 0 and 100 ?
Thanks in advance

Re: How to specify the minimum length of text-boxes ?

Posted: Wed Aug 28, 2019 6:14 pm
by amosbatto
It depends on your range of numbers. Sometimes you can do it with regular expressions.

This will allow 0-100:
^(100|[1-9][0-9]|[0-9])$

This will allow 1-99:
^([1-9][0-9]|[1-9])$

However, if you have a complicated range, then you might need to use JavaScript like this:
Code: Select all
//set the minimum and maximum values (inclusive) allowed 
minVal = 284;
maxVal = 5839;

$("#amount").setOnchange(function(newVal, oldVal) {
    var iVal = parseInt(newVal);
    if (iVal < minVal || iVal > maxVal) {
        alert(newVal+" is outside permitted range between "+minVal+" and "+maxVal+".");
    }
});

Re: How to specify the minimum length of text-boxes ?

Posted: Thu Aug 29, 2019 12:02 am
by mamad71
Thank you so much