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

Exact length #672

Open trusteddigital opened 6 years ago

trusteddigital commented 6 years ago

I may be missing something here but I've dug deep and can't find what I'm after. I want to validate on an exact length of string.

It's for a number which must be 11 digits long. So I'm using

<input type="text" data-validation="length" data-validation-length="11">

However whenever the input is not 11 digits, I'm getting the error

"The input value must be between 11 characters"

Rather than "must be 11 characters"

I understand that it's interpreting this as a range. The Readme itself states

"length — min/max/range"

Is there another function for doing exact lengths. Is it edge-case? Seems like a fairly reasonable thing to be able to want to do.

Thanks!

trusteddigital commented 6 years ago

Clearly in this example I could have a custom error stating the exact 11 character requirement

victorjonsson commented 6 years ago

You'll need use the custom message attribute data-validation-error-msg or data-validation-error-msg-length if you have combined several validation rules.