Problem/Motivation

When a field has the `min` and/or `max` attributes set, the validation message is incorrect.

Example

If a field has the following attributes:

'#min' => 1,
'#max' => 10,

On the front end, if a number less than 1 is entered, the error message that is currently displayed is:

The value in @field has to be greater than 1.

If a number greater than 10 is entered, the error message that is currently displayed is:

The value in @field has to be less than 1.

Although both 1 and 10 are both valid entries, the messaging informs the user that they must enter something greater or less than those amounts.

Proposed resolution

Instead of the error messages being 'greater than' or 'less than', they should be changed to 'greater than or equal to' and 'less than or equal to'.

Comments

Rob Howells created an issue. See original summary.

rob howells’s picture

StatusFileSize
new1.24 KB
nikunjkotecha’s picture

Version: 3.0.1 » 4.0.x-dev
Status: Active » Needs review
sandeep_k’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new61.83 KB
new44.63 KB
new44.13 KB

Verified and tested patch 3362408-min-max-messages.patch on the Drupal version- 9.5.12-dev. The patch was applied successfully and looks good to me.

Testing Steps:

  1. Install the Clientside Validation module
  2. Go to Extend> Look for Clientside Validation module and install it.
  3. Go to Contact form, add number field
  4. Add min & max limit to the number field & verify validation message on the form
  5. Download this patch and Apply.
  6. Reverify the validation message on the contact form

Testing Results:
Validation messages are not changed.

Moving this ticket to RTBC.

nikunjkotecha’s picture

Status: Reviewed & tested by the community » Needs work

Thanks Snadeep.

We will need tests for this so moving to needs work.