How to validate the Time control on a Date/Time

  • 13 August 2018
  • 3 replies
  • 4 views

Badge +11

Hi,

I am trying to validate the TIME on a date/time function.
I manage to validate the date but the time is always set to 00:00 by default.

If someone does pick the date but not the time > the validation goes through.
However, it is important that the user also picks the relevant time.


Yes, the process is to set the time but some users do not follow the instructions.
How would I be able to validate if the time is set to 00:00 then display error "please select the time..."

Current validation is set to:  BookingDateTime < Current Date && Is New Mode


3 replies

Userlevel 5
Badge +13

Hi Bim.  I think I was able to figure it out.  Try the steps below and let me know if it works for you.

  1. Add a "Calculated Value" control to the form.
  2. Set the formula for the "Calculated Value" control to:  formatDate(DateControlName, "hhmm")
    1. DateControlName is the name of your Date/Time control on the form.
    2. The result of the "Calculated Value" control would be "0000" by default.
  3. Add a form validation rule to your Date/Time control and configure it like:
    1. Rule Type = Validation
    2. Condition = contains(CalcValueControl, "0000") where CalcValueControl is the name of the control created in Step 2.
    3. Message = Enter your message
  4. That should make the Date/Time input control invalid if the date/time is not changed.
  5. Also, you'll probably want to create a rule to hide the "Calculated Value" control.

Nintex Forms 2013 - Date Validation 2

Nintex Forms 2013 - Date Validation 1

Nintex Forms 2013 - Date Validation 3

Badge +11

Hi Eric

This is what I already tried and strangely it does not work at all!
The calculated field does not show any figures when running a test ....

However, the calculated value shows the value only when the form has been submitted.
Therefore, I think there is a JavaScript which forces the field to automatically update but unsure how that is done happy.png

The BookingDateTime format is set to: Standard.

Badge +11

UPDATE

I have come across the following article in the forum: Validate Time portion of date/time control in a form

whereby Marian Hatala suggested the following formula as a validation

equals(formatDate(StartDate,'hhtt'),'12AM')

 

In my case, I am using the 24hr date format and had to change the formula as following:

equals(formatDate(BookingDateTime,'HHmm'),'0000')

RESULT

in hope there won't a be a flight at 00:00 lol

Reply