Hi

I am trying to validate a number field. I need the field to have a minimum of 9 digits and a maximum of 14 digits. I have tried both the Min Length/Max Length settings and tried using the reg expression [1-9][0-9]{9,14} in the Pattern field but neither are throwing up an error with Clientside Validation. If I turn off Clientside Validation the form displays the error using either method if the field does not validate.

Also, if I leave the field blank and have it marked as required, Clientside Validation is not displaying the Custom Required Error Message - it displays the default "Number is required' message.

Any idea?

F

Comments

frankdesign created an issue. See original summary.

frankdesign’s picture

Sorry

I should clarify, when I said Clientside Validation is not throwing up an error, I meant to say it's not displaying the error inline like all other validation errors. The error is displayed but as a standard error message at the top of the page.

F

sgohil1’s picture

@frankdesign - i know this is a year old post, but was wondering if you have found the solution?

I have the similar situation where i have Composite element with #pattern = [0-9], but it does not throw the error when the clientside_validation_jquery module is enabled. If i uninstall the module, it throws the default error (not displaying the message, but changing the textbox border to Red).

Thank you.

frankdesign’s picture

@sgohil1 - I gave up on Clientside Validation. The D8 version hasn't been updated in nearly 2 years and I couldn't find a solution to the issue. For the moment, I rely on Drupal's Inline Form Errors and browser HTML5 Validation. It's not the perfect solution, but it works.

F

sgohil1’s picture

@frankdesign - Thanks a lot for your quick response. I believe I'll either have to write a custom module or go with the route you went!

nikunjkotecha’s picture

Hi @frankdesign,

For the custom required message, it is done now in latest dev version. I was waiting for few core bugs to be fixed before releasing the new/stable version but it seems it is going to take a lot of time in core so I'll release a new version sometime next week.

For the regex error, I don't think there is anything supported in the module for now, we can for sure add support for it. I'll check next weekend once I'm back from vacation. I understand you are not using this now but in case you get a requirement again and use this, feel free to create custom plugins and contribute back :)

Thanks,
Nikunj

nikunjkotecha’s picture

Category: Bug report » Feature request