Any way to get raw input text from date field?

Hi All,


I’m working on a date-field validator, and I find I need access to the actual, raw text entered by the user. Unfortunately, I can’t seem to find it.


Here’s what I’ve got:

  • standard Date field displayed on a Form
  • Fragment’s “Validator” setting pointing to my new Fragment Validator
  • User (me) enters 12345, obviously not a valid date


    Within my Validator is this code:
    // retrieve the input string
    let input_string = fragment_presenter.get_value();
    cs.log('input string = ’ + input_string);


    In the Detective I get this:
    11:36:38.1686 input string = 1969-12-31 00:00:00
    Obviously, not what I want since this looks very much like a valid date.


    Changing “get_value” to “get_displayable_value” yeilds this
    11:38:34.8434 input string = Wed, 31 Dec 1969 (occurred 4 times)
    Also unhelpful.


    So, is there a way to get the raw, un-processed text string from a date (or any other) Fragment?

Thanks,

Randy

Hi Randy,

There are few functions that are available - get_editable_value(), get_displayable_value(), get_html_displayable_value(), get_values() and get_value(). I assume the closest one would be get_editable_value, but I’m not sure if that will return the format that you need.

If none of the available functions return the raw format, you could add a custom CSS class to the presenter, then get the value using the DOM element with that css class?

Regards,
Richard

Hi Richard,


Sorry for the delayed reply.


I’ve tried all of the “get_xxx_value” variants, but no joy. They all return a formatted date string, even when the entered data wasn’t one. “get_html_displayable_value()” returns a “not a function error”. I’ve not messed about with the DOM, and it’s overkill for what I wanted to do. This was for a little validator I was playing with so nothing urgent.


Perhaps an enhancement for a future release? This could cause someone a problem if they didn’t realize that the value is always a valid date, even when the input data isn’t.

Regards,

Randy