victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

Issue handling dates containing dashes in the logic module #640

Open nancystodd opened 7 years ago

nancystodd commented 7 years ago

There is an issue when using the logic validation module on a field that depends on a date value. If the value in the data-validation-depends-on-value attribute is a date in a format containing a dash, the value is split into segments wherever there is a dash. For example, if the date validated is <2007-02-02 00:00:00.0>, the split function returns the value as an array of values, like this: {"2007","02","02 00:00:00.0"}, thus failing to match the actual field value when the values are compared.

I traced the problem to the split function in the jquery.form-validator.js file, which allows splits by any of four delimiters (space, comma, dash or pipe). Since this date format is a legitimate date format, this can be a problem. As a "lazy" workaround, I eliminated the dash in the split function, but this probably needs a change to the split function to allow or disallow certain delimeters as is already done with the allowSpaceAsDelimiter param or perhaps, allowing the user to specify the delimiter they are using to separate values instead.