Think she dates examples plsql validating for in the best

How often have you already created an APEX validation to make sure that a money amount is greater or egal to 0.00, a percentage value is between 0 and 100 or that an entered date is less or equal to today?

There is some work involved doing that.

  1. You have to create a validation to make sure that the entered value is numeric.
  2. Create another validation which only fires if the previous one returned OK.
  3. Enter the check as PL/SQL expression or SQL Expression
  4. Think about a good error message

All that just to check that the amount is greater or equal to 0… Another drawback is that the user only gets this error message when he submits the page, so if you want to give him immediate feedback in the browser you have to do the same checks with JavaScript…

Hmmm, there has to be an easier and faster way to do that.

There is! 🙂

I added a declarative range check for Page Items/Tabular Form Columns in the recent release of the ApexLib Framework.

You can try it on my Feature demonstration web-site.

It’s now possible to define the min-/max value for a field/column. This boundaries are checked immediately in the browser when you leave the field and for security reasons the same check is also done when you submit your page to the server.

You just have to put the ApexLib hints $APEXLIB_MIN_VALUE=min value$ and/or $APEXLIB_MAX_VALUE=max value$ into the Page Item comment or Link Attributes of Tabular Form Columns as you already do for other ApexLib hints.

What’s supported?

You can assign fixed values. Eg. $APEXLIB_MIN_VALUE=0$ $APEXLIB_MAX_VALUE=100$ to do a range check or use $APEXLIB_MIN_VALUE=01-JAN-2007$ to check against a fixed date.

But you can also make it more dynamic and reference other Application Items/Page Items. Eg. $APEXLIB_MAX_VALUE=&F111_TODAY.$ to check that the user doesn’t enter a date which is greater than today.

For Tabular Form Columns you can also use the #COLUMN_NAME# notation to reference a column cell value of the same row. Eg. $APEXLIB_MIN_VALUE=#SALARY#$

If you reference a page item/column on the current page, the min/max value changes when you modify the referenced field.

Note: The values specified, independent if they are fixed or dynamic have to comply to the format mask of the current item/column!!! That means, if your current date picker has DD-MON-YYYY as format mask, the fixed or referenced dynamic value also has to be of that format!

For our above example with the application item F111_TODAY, the corresponding initialization code would be a PL/SQL expression with the following code (we assume the used format mask is DD-MON-YYYY)


What doesn’t work (yet)?

It’s not possible to enter an expression. For example to reference another field and add 1 day. eg. $APEXLIB_MIN_VALUE=&P4_VALID_FROM.+1$

But I think it’s a good start for now and can save some development work!

BTW, I have also update the “Set” configuration for the ApexLib hints in the case you are using the APEX Builder Plugin. You can find the files in the “BuilderPlugin” directory.

This entry was posted in ApexLib and tagged client side validation by Patrick Wolf. Bookmark the permalink.