Skip to Main Content
Feature Request FR-3780
Product Area Page Components
Status CLOSED

5 Voters

HTML5 Item Validation Pattern and Error Message

greg Public
· May 3 2024

Idea Summary
Declarative options for providing a pattern and an error message for mismatches on Page Items like email addresses and phone numbers.

Use Case
While there are subtypes for Page Items like Phone and Email, these do not allow the developer to customize the pattern or message. Currently the Phone type does not validate a pattern but if provided with a Custom Attribute “pattern=”my custom format here" it will validate it. However the error message (client side validation) reads “Please match the requested format” which I believe it the default browser message.

It would be nice to have declarative options for both the pattern to match and the message displayed.

Preferred Solution (Optional)
In the Item attributes, under Validation, add a Pattern (to match) attribute and if entered also an Message on Match Error attribute.
and/or
Add some more builtin options to the list of subtypes that do client side validation.

This request is likely a duplicate of FR-222.

Comments

Comments

  • greg OP 1 years ago

    Similar but no one mentioned html5 and I see a lot of ideas for pulling pl/sql validations into client. We already have a little of this built into the email type, the number type, ranges of numbers. Just asking to open this up to patterns and then allowing something like apex.message.showErrors to work on a single item.

  • greg OP 1 years ago
    currently I am using 
    
    let validity, theItem, errors;
    validity = true;
    errors = [];
    
    theItem =apex.item(this.triggeringElement.id);
    apex.message.clearErrors(this.triggeringElement.id);
    
    validity = theItem.getValidity();
    
    if (!validity.valid) {
        errors.push({
            message: theItem.getValidationMessage(), // customize on item with data-valid-message custom attribute
            location: 'inline',
            pageItem: theItem.id
        });
    }
    
    apex.message.showErrors( errors );