[luci]how to dynamic modify datatype: 'rangelength'

var pwd1 = s.option(L.cbi.PasswordValue, 'password', {
                        caption:     L.tr('Password'),
                        datatype:    'rangelength(8, 64)'
 }).depends('mode', function(v)){
              if(v == 'hard')
                        pwd1.options.datatype='rangelength(13, 32)';

In init, set the password range length from 8 to 64. I want to change the 'rangelength' to 13-32 when mode = hard, but the 'rangelength' is not modified.

How can I fix it?

(Moved to the For Developers section.)

How about defining the min and max length as variables before the pwd1 declaration. Then you could first evaluate "hard" fand set the variables accordingly, and then use these variables in the pwd1 rangelength declaration.

IMHO just use client side javascript for that. As an example implementation check this PR where a password strength check was added to LuCI password dialog: https://github.com/openwrt/luci/commit/7383bf054ad5bcdca53fcc2c4861c708aacb83b9#diff-74dd0f97783756f60d7037093ed43fca