my code has to be like this:
rules: {
jform[name]: {
required:true,
minlength:5,
maxlength:15
},
how should I use those square brackets? There are a lot of answers regarding this subject found on this website and on google, but not particularly for this one.
I’m guessing you want the value of
jform[name]to a key in the object. You can’t use variables as keys when declaring an object literal. You’ll have to add this key as another statement.Example:
If you want the key to literally be
jform[name], then you need to use quotes around the key.