admin管理员组

文章数量:1394068

I have a form with a date selector field where I set (static) min (-10y) and max (-3y) dates. But I have also defined custom validations for more exact error messages. But in testing I only see the system standard error message (Datum muss zwischen 11.03.2015 und 11.03.2022 liegen.) and not my custom ones when I leave the min and max dates in - when I remove them the custom validations work fine, but of course the disadvantage of this is that the date picker is not restrained to the valid time slot anymore. Question can I do both (have min and max dates) and see my custom validations or do I have to choose one of them? I think the issue is that the default check happens before any custom ones (I have given them the lowest sequence possible (0) but no use) and then the custom ones are ignored, but I don't know how to prevent this.

I have a form with a date selector field where I set (static) min (-10y) and max (-3y) dates. But I have also defined custom validations for more exact error messages. But in testing I only see the system standard error message (Datum muss zwischen 11.03.2015 und 11.03.2022 liegen.) and not my custom ones when I leave the min and max dates in - when I remove them the custom validations work fine, but of course the disadvantage of this is that the date picker is not restrained to the valid time slot anymore. Question can I do both (have min and max dates) and see my custom validations or do I have to choose one of them? I think the issue is that the default check happens before any custom ones (I have given them the lowest sequence possible (0) but no use) and then the custom ones are ignored, but I don't know how to prevent this.

Share Improve this question asked Mar 12 at 14:46 user3284214user3284214 331 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Your observation is correct. The issue is that there are client-side validations and server-side validations. They have a different execution point which I agree can cause confusion. It's not possible to change the order in which they are executed.

The client validations are declarative attributes (eg the "value required" attribute of an item or the date attributes you mention) and are executed before the page is submitted.

The validations defined in the "Processing > Validating" section are the server-side validations. Those are executed after the page is submitted.

The behaviour is that when a user submits the page, first the client side validations are performed. If any validation fails, processing does not continue. Only when all client side validation pass, the page is submitted and the server-side validations are processed.

I'm pretty sure you cannot do both and define both a declarative validation and a server-side validation for the same condition. This is because the custom validation is only fired if the client-side validation passes.

What you could do however, is modify the system error message that is generated by the client-side validation.

To do this, follow the following steps:

  1. Invoke the message so you can see the complete syntax:

2. Determine the message name of the message. Open browser dev tools, navigate to source and look for the js_messages file. In that file, search for the message:

In this case, the message is APEX.DATEPICKER.VALUE_MUST_BE_BETWEEN

  1. Create a text message with the same message name. This is done in Shared Components > Globalization > Text messages.

Notes:

  • Make sure to set the "use in javascript" attribute to "On"
  • The original message in the js file has the values \u00250 and \u00251. \u0025 is the unicode representation of '%'. When creating a text message, the % sign does not need to be escaped and the values %0 and %1 can be used (see screenshot below)

  1. Save, reload the page and invoke the message again. Observe the changed message:

本文标签: How to use custom validations before system ones in Oracle ApexStack Overflow