[closed] ftLimitMin doesn't appear to work

#1

Hi,

While working on a form I used the ftLimitMin option for a longchar ftType however it doesn’t appear to work. What I was expecting was formtools wouldn’t allow the form to be submitted because the minimum about of text hadn’t been entered.

When I turn debugging on I noticed it generating:

TypeError: $.validator is undefined

In core/packages/formtools/longchar.cfc on line 151 is

<skin:onReady><cfoutput>$.validator.addClassRules("rangeLength", {rangelength:[#arguments.stMetadata.ftLimitMin#,#arguments.stMetadata.ftLimit#]});</cfoutput></skin:onReady>

So I tried changing $.validator to $j.validator and the error stopped however it still doesn’t force a minimum amount of text to be entered. Is this not how this should work?

Regards
Mark

#2

The $. instead of $j. is definitely a bug.

According to the docs, “rangelength” is the name of the rule but the code looks like it says “rangeLength” with a capital “L”, can you try making that lower case and see if that fixes it?

#3

I changed it to all lowercase and confirmed in the source view that I was now using the changed code but nope, no difference. Allows the field to contain empty value even though there is a min length set.

#4

Justin, I set the ftLimitMin to “2” and just noticed that if I try to submit the form with nothing in the field it submits when it shouldn’t. However if I enter a single character in the field, I get a validation warning that I must enter a value between 2 and 1000 characters.

#5

Ahh ok cool… Perhaps you will also need ftValidation="required" to enforce a required value, in combination with the minimum length.

I’ll do the above couple of bug fixes now :smile:

#6

Try adding ftValidation=“required”. It sounds like the library makes a
distinction between a value of invalid length and no value.

Blair

#7

Fixed for p700, p710 and p720 :smile:

I didn’t end up changing it to lower case because that looks like it’s just a class name, it should be fine to stay as is – the rule name itself was already lower case.

#8

Thanks Justin and Blair. ftValidation was required to make it kind of work however now what I have just noticed is that if I type a single character into the editor the counter doesn’t go up. If I type in 2 characters the counter says 1. Maybe something wrong with the way it is working out how much text is in the field that was screwing up the validation?

See below:



#9

Does it update to the correct number when the field loses focus? I’m thinking there’s a dodgey event binding somewhere…

#10

Nope. And also noticed something interesting:

If I type in abc the counter says “2”. Hit backspace to remove the ‘c’ and the counter goes to 3. Hit the backspace 2 more times (so all text is now removed) and it says 1. Hit backspace OR press any arrow key and it goes to 0. I’ve double checked to make sure there isn’t a space or something I couldn’t see in the field but there isn’t anything.

#11

@mpicker this commit from @jorgenskogas should fix that:

Went through in the latest 7.2.1 release.