Number field - Format mask and validation

APEX 4.2.1
When a page item with source=DB column uses a Number type and a currency format mask (FML999G etc), when the page is rendered, it properly formats the number.
The built-in Item is numeric validation appears to be handle this reasonably ok. i.e. both formatted values and only-digits both validate ok.
But any after-submit validations choke on the non-numeric characters in the field! Please don't tell me I have to a) create shadow items and/or b) replace() out the non-numeric characters in the validation.
After so many years and versions, why doesn't APEX have a simple, declarative, elegant solution to handle such a basic function?
Am I missing something?
Thanks

As described in the item help
"Select or enter a format mask. Note that format mask is applicable only to items of source type Database Column."
In my experience, and this goes for the great web experience, not just the application you're designing - I've found the most data entry fields avoid formatting.
Relevant information is often shown item labels.
Any occasional the business has specifically asked for formatting, I've taken the same approach as I've needed to for years - before web development (and every time you use the to_date/to_char functions for date conversions) - validate the information as per expectation. If you think the user will be adding punctuation to a numeric field, then you must validate accordingly.
This usually means adding TO_CHAR(value_entered, expected_format_mask) to your validation control, instead of presuming APEX will read the user's mind and know the content of that numeric field may not be numeric.
Date entry does the same thing - ultimately there is a session date format that is implicitly used by Oracle to convert an entry of 12-10-2012 to the appropriate date -- ie, is it October or December?
Have a think about the various websites you visit personally - plane bookings, concerts, ebay, etc - how many expect entry to be purely numeric? My recollection is most, except maybe some credit card fields, but most use some sort of regular expression to sort that out. And you can tell the validation is coded respectively.
Generally, I reserve this sort of primping to reporting - even then it's made to be subtle - just like I'd prefer makeup to be ;-)
Most users just care about the data, not how it looks.
Scott
blog: [url grassroots-oracle.com]grassroots-oracle.com
twitter: [url twitter.com/swesley_perth]@swesley_perth
-- please mark any useful posts as helpful or correct, in the end it helps us all

Similar Messages

  • Problem with Format Masks and Computations

    (I did a quick search on this, but didn't notice another thread on the topic. If there is already one I apologize.)
    We are using APEX version 2.2.1.00.04.
    I had an editable item that had the 999G990D00 format mask. In a computation I used that item and another item (that didn't have a format mask) to calculate a third item. The item I was trying to compute would not populate. It really had me stumped, so I went so far as to completely delete the fields and re-construct everything. When I did so the computation worked. That is until I put the format mask on the item again. I removed the format mask and the computation now works.
    Is this a known issue? Is it a bug? Am I doing something wrong?
    Thanks, Tony

    Tony,
    As Patrick mentioned, all variables in Apex are strings. Whenever you do something with them that effectively requires something other than a string value the database does an implicit type conversion. This often works, but not in cases where the db doesn't know how to do the conversion. For example, if your default database date format is dd-mon-yyyy and you have a string 10/09/2007 the database won't have any idea how to convert it to a date. That same is true for number formats.
    In your case, you used the number format mask in apex to convert a number to a string witht the given format. Apex does not do anything to convert it back to a number when you submit the page (unless you use the built in row processing). If you want to do anything with it as a number, you need to change it back with the to_number function. The second parameter is the format mask of the string you are passing in.
    Hope this helps,
    Anton

  • Whole number field formatted as timezone in CRM 2013 SP1UR1 gives error on saving

    Hi,
    I added a whole number field formatted  as time zone to the appointment form and when I save the record I get an error saying
    Crm Exception: Message: An unexpected error occurred., ErrorCode: -2147220970, InnerException: System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.OptionSetValue' to type 'System.IConvertible'.
    This error is coming from the timezone field and only happens when I have data in the field. Has anyone seen this?
    Thanks
    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    More info, the error occurs on pipeline stage 30 of the Book or Reschedule message and the same thing happens in CRM 2015. I've started a thread on connect with URL
    https://connect.microsoft.com/dynamicssuggestions/feedback/details/1128206/crm-2013-sp1ur1-cant-handle-the-timezone-field
    This must be rather new because I've tried it in CRM 2011 UR late and it did not occur there, I haven't tried CRM 2013 RTM though so I can't say if it's a CRM 2013 or a CRM 2013 SP1UR1 issue.
    BTW, the 2015 org was a complete vanilla so I've pretty much ruled out custom code as a culprit :)
    Regards
    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

  • Character field format mask

    since Oracle Reports doesn't allow character data format masks, whats the work around to format telephone numbers, etc. without having to store them as a number data type?

    You can store the telephone number in the database as a varchar2(12) with the format. Say the user enters 3331114444 then while inserting the value change it to 333-111-4444 and store it. Else in the report convert your telephone number to a number field and format it.
    Select to_number(telephone_no) from table;

  • Text field - format mask

    Hi!
    How can I achieve that tex field will have formated mask like AB12 12345 123 123 1234 (first 2 signs are character - only AB, then there is 17 numbers with space), so when I write in that text filed numbers like 123451231231234 I get AB12 12345 123 123 1234? I don't know if I must use regular expression or something else.
    I use apex 4.1
    Regards,
    drama9346

    You can do this using javascript like in this example:
    http://apex.oracle.com/pls/apex/f?p=31517:127
    However, your requirement is more complicated and will need more coding.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    http://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Format masks and IR searching

    Hi all,
    We have an IR in which we have formatted a number field. Instead of 47 the user will see 47,0.
    In the search field in the IR I am only able to search for 47 (the database value), which is perfectly logical. But is there a way to search in the 'formatted numbers'?
    Thanks,
    Maurice

    Good morning Rob,
    Nice to talk to you.
    the following is a cutNpaste from the OFGTEL65 lib.
    BEGIN
    /* Begin Headstart Customization */
    qms$errors.show_debug_info ('ofgtel.pll, procedure cgfk$lkup_qry.extend_where, headstart 5.0.6 custom version');
    The following is from the "About this Application" window...
    Oracle9i Enterprise Edition Release 9.2.0.2.0 - 64bit Production
    Oracle Forms Generator 6.5.40.4.0
    Headstart Template Package 6.5.1.0
    Template Form (qmstpl65) 6.5.0.6
    Object Library (qmsolb65) 6.5.1.4
    Event Handler Library (qmsevh65) 6.5.1.5
    Core Library (qmslib65) 6.5.1.12
    CSLS Application Library (cslsapp65) 3.0
    CSLS Business Rules Library (cslsbr65) 3.0
    CSLS Common Routines Library (cslscom65) 3.0
    Does that answer your question???
    If this is not the version you are using, please tell me the Headstart patch number that includes the latest libraries and please tell me where I can get a copy of the latest OFGTEL pll so I can compare the code.
    Thank you very much,
    Michel

  • Problem with format mask and currency

    Hi,
    I am trying to apply a format mask to a report column.
    I want my format to be: 4500 ==> $4,500.00
    I have tried to apply: FML999G999G999G999G990D00, and i get #4,500.00
    Do i have to set a currency parameter somewhere for this format mask to work?
    I have done a select * from nls_database_parameters:
    NLS_LANGUAGE AMERICAN
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET US7ASCII
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    Thanks in advance,
    Immanuel

    Immanuel,
    Here's what I believe is going on:
    1) Your database character set is US7ASCII. US7ASCII cannot store a '£' character.
    2) Although the real NLS_CURRENCY symbol for NLS_TERRITORY UNITED KINGDOM is '£', it's displaying a converted character of '#', due to the above reason.
    3) The currency symbol from the format mask is determined by your NLS_TERRITORY (and hence, your NLS_CURRENCY) settings for the session.
    4) Your application is most likely setup to run with an application primary language of English United Kingdom. Thus, your application will always set NLS_TERRITORY to UNITED KINGDOM.
    To get your desired result, either:
    1) Change your application primary language to en-us
    or simpler yet
    2) Hard-code the $ sign in your format mask.
    Joel

  • Editing a field in ALV and validating the newly entered Value

    Hi Experts,
       I have an ALV report in grid display (not object oriented). My requirement is to edit a field on the output and write the validations to validate the value that was edited on the ALV output.
    This can be done using object oriented coding by using the method check_changed_data. For this to happen, i need to change the entire scope of my report into object oriented, which is like reinventing the wheel.
    Since my report was developed using classical ABAP, what needs to be done to get this functionality. Any suggestions are welcome.
    Thanks.

    in the FM 'REUSE_ALV_GRID_DISPLAY'  import parameter IS_LAYOUT check out the columsn EDIT and EDIT_COLUMN. Also Use FM 'REUSE_ALV_EVENTS_GET' to get list possible event and pass a subroutine name which will be called when ever event is fired.
    example:
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = l_events.
      READ TABLE l_events WITH KEY name = slis_ev_top_of_page
                                   INTO g_event.
      IF sy-subrc = 0.
        MOVE top_of_page TO g_event-form.
        APPEND g_event TO t_events.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_buffer_active    = 'X'
          i_callback_program = t_repid
          is_layout          = t_layout
          it_fieldcat        = t_fieldcat[]
          i_save             = t_save
          it_events          = t_events[]
        TABLES
          t_outtab           = g_editpos1[].

  • Import number fields with scale and precision

    When i import data to create a new table, how do i specify the scale and precision when importing ? ...or do i have to create the table manually and then import to an existing table?

    The Data Workshop wizard allows you to specify the scale and precision for numeric columns.

  • How Can I Change Format Mask For All Fields that type's Number Depend on Parameter in Report Builder 10g ?

    I want Change format mask for all fields that type's number
    Such as
    if  :parameter_value = 1 then
       all fields format mask = ' 999,999,990.000' ;
    else
       all fields format mask = ' 999,999,990.00' ;
    end if;
    Regards

    So, i have bad news for you : you'll have to rebuild again.
    Meanwhile i have excellent news for you : there's an online tool made by Johannes Henseler called Sidecar xml which builds the necessary xml file for you, sort of what you find in the Digital Publishing Folio Editor website, but saves it in your Folio folder.
    Next time you import all your folder (with that file), it will place all the necessary information, and even reorder the articles.
    Build once, play many times.

  • Date format mask failure stops navigation

    I'm trying to allow users to enter dates in multiple formats.
    My date items already have format mask 'YYYY-MM-DD'.
    I have added ON-ERROR code that handles errors like FRM-50003 so that users can enter '29-APR-2011' and the error handler fills the date item with '2011-04-29'.
    However, when users enter '29-APR-2011', then tab out of the item, the format mask error stops navigation to the next item. The user needs to tab a second time to actually leave the item.
    There are no FORM_TRIGGER_FAILURE exceptions in my code that would stop navigation to the next item.
    How can I allow users to enter data in formats other than the one I've specified for my format mask, but not have to tab twice to exit the item?
    I know that I can add a KEY-NEXT-ITEM trigger like the following. Unfortunately, I would have to re-write much existing code.
    enter;
    next-item;
    I know that I could remove the format mask and let WHEN-VALIDATE-ITEM handle things. But then I have to add validation code to all my date items. I really just want to write one piece of code that is called from ON-ERROR so that I don't have to re-write all existing code.
    Suggestions?
    Thanks,
    -Ken
    Edited by: Ken Anderson on May 27, 2011 3:12 PM

    With FORMS_USER_DATE_FORMAT you can specify different allowed input masks without having code in your form. Heres some more info Re: Date field in 10g Form

  • Creating a Simple Number Field

    I want to basically create a JTextField only instead of text, numbers including decimals. I tried putting number into a text field but java won't see them as double. I tried the tutorial example with a formatted text field, however, they explain abstract and listeners for validating which I could care less about. I also tried the following code from the tutorial which doesn't work.
    JFormattedTextField ftf = new JFormattedTextField();
    ftf.setValue(new Number(100));
    The compiler says Number cannot be instantiated as it is abstract. How can the tutorial do it? I have had the same problem with other examples in the tutorial such as the Border examples for creating compound borders. The examples don't work because the compiler says Border is not instantiable. It is frustrating. Any help with a simple number field for setting and getting the int or double values as numbers. Thanks.

    Read this section from the Swing tutorial. It does exactly what you want and provides code as well:
    http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html

  • Date format Mask for CHAR datatype

    hi
    i want to assign a format mask like 'dd/mm/yyyy' to a field which has char datatype can i ?

    The quickest answer to your question is to try it! :-) If you click on the Format Mask property of your Text Item and then press F1 Forms will display the Format Mask Help information for this property. All of the valid combinations for a Text Field Format Mask will be displayed.
    To answer your question, you can put a format mask on a Text Item that can enforce the basic format of 'DD/MM/YYYY', but you could get data like: 99/99/9999. You would have to write code in a When-Validate-Item trigger that would ensure the user has entered a valid date.
    Hope this helps.
    Craig...

  • Date Format Mask On Unbound Item

    Hello everyone!
    I have a module with some unbound items. One of them is date_completed. I gave the item datatype DATE and formatmask "DD-MM-RRRR". But in the application, when I type 290108, I get FRM-50026 "date must be entered like : DD-MM-YYYY.
    But I gave the item a format mask!
    Can somebody help me?

    But I gave the item a format mask!Then enter it in the format mask and not as a number
    It is doing exactly what you are telling it to do
    Nicolette

  • Commas in a number field

    I have developed a web site for a real estate agency for which I have built a custom web app. The web app has a number fields that display information about individual properties in both list and detail formats. Some of the fields I created in the web app are "number" fields. I used number fields for price and square feet because I also have a search form linked to the web app. I needed to have a min and max search capability for these two fields, which the "number" field provides automatically. However, being a "number" field, it does not allow for the use of commas in the field, which is a client requirement. If a comma is used in the web app field, the display is null. For example, the client needs the price to be displayed like this (1,300,000) vs (1300000). Here is a link to the test site: Anne Rogers Realty Group, Inc - Featured Listings.  Note the price and square feet fields on both the list an detail views for the properties. Is there any way around this problem? Thanks in advance

    Well you can do anything from developer's perspective but asking client to put same value twice can make you look unprofessional.
    Here's what I did for many house listing websites.
    1. Client puts price in pure number format ( e.g. 500000 )
    2. wrap the price value with a tag in List/Detail template e.g.   <span class="house-price">{tag_price}</span>
    3. then at the end of the page put a jQuery snippet which would globally format the prices ( e.g. $('.house-price').formatCurrency(); )
       Here's one I use
      https://code.google.com/p/jquery-formatcurrency/
       even if you're not familiar with jQuery it's pretty easy to follow
    No more complain from client

Maybe you are looking for