I have a unit length that accept entering cm, inch and ft. I know how to set-up the input validation in one limit. Let say, I want to have max limit to 100cm. I can set the field validation to the following:
<input name="length" type="text" data-validate="{required:true, max:100}" />
And let say, I have a select field that contain the unit of length:
<select name="unit">
<option value="cm">cm</option>
<option value="inch">inch</option>
<option value="ft">ft</option>
</select>
The problem is: If I enter 100ft or 100inch, the validation still pass. How can I adjust the max
value when I switch the unit? So that 100ft or 100inch cannot pass the validation.
Best Answer
Finally it's just the matter of JS. First of all, modify the select list a bit:
Then, write the following JS. You can load it right under the select list, or via requirejs:
I just solved it long time ago, but forgot to answer it till now.