jQuery-Form-Validator icon indicating copy to clipboard operation
jQuery-Form-Validator copied to clipboard

"depends-on-value" and negative values

Open lllopo opened this issue 6 years ago • 1 comments

Hi, I'm trying to make an inut working with "depends-on-value" property, which depends on "-1". Since the regex in the split function is "'[,|'+(allowSpaceAsDelimiter ? '\s':'')+'-]\s*'" , which means it splits on "," , "|" and "-" if I get it right and so - depending on a negative value seems rather impossible. The split actually converts the "-1" to an array of "empty" and "1". Is this correct or I'm missing something ? If it is correct - then this seems to be a huge shortcoming, then.

lllopo avatar Mar 29 '18 11:03 lllopo

Having the same problem. For myself, I've addressed this by changing logic.js

listWithRequiredValues = $.split($input.valAttr('depends-on-value'), false, false),

to

listWithRequiredValues = $input.valAttr('depends-on-value').split(/[,|]\s*/),

I actually think a better delimiter is an unlikely-to-be-used character like the pipe |, or perhaps the double-pipe ||, but this would potentially be a breaking change to anyone who was using dashes as delimiter (but seriously, who does that?).

wunc avatar Sep 19 '18 16:09 wunc