Skip to main content
Nintex Community Menu Bar

Getting a Field with \Time only\" in Nintex Forms"

  • April 19, 2016
  • 12 replies
  • 125 views

Forum|alt.badge.img+3

Hi fellow Nintex Admins,

in InfoPath i can set a text field to "time". Is there a way to achieve this with Nintex Forms?

Cheers

Daniel

12 replies

Forum|alt.badge.img+9
  • Scholar
  • April 19, 2016

If you have a date with time you can extract just the time using the Build string action and save it to a variable/text field:

fn-FormatDate({ItemProperty:Modified}, "t")

If you want to capture the current time you can use the Current Time reference and save it to a variable/text field.

2016-04-19_10-04-38.png

Hope this helps.


Forum|alt.badge.img+3
  • Author
  • April 19, 2016

Hi Igor,

thank you for your answer, but this is not what i am looking for.

In my case, the user has to add hours / minutes. I have a date / time field in the same form, so it would be nice to stay in the same usability logic.


Forum|alt.badge.img+9
  • Scholar
  • April 19, 2016

In this case you might want to use the Calculate date action and add hours/minutes to the existing date.


Forum|alt.badge.img+3
  • Author
  • April 22, 2016

I think wie are talking about different things happy.png

The user has to fill out a Nintex Form in a library. In this form is a field, where the user has to add a time. There is no date or no workflow involved in this situation:

183048_pastedImage_1.png

Uhrzeit = time

Cheers

Daniel


Forum|alt.badge.img+13
  • Novice
  • April 22, 2016

So I think it looks like you're looking at a text box with a set format so it's input in time. Perhaps Regex validation would be your best bet?


Forum|alt.badge.img+9
  • Scholar
  • April 22, 2016

So why not just use the date & time format?

2016-04-22_8-12-34.png

You can then format and display it in multiple ways.


Forum|alt.badge.img+3
  • Author
  • April 26, 2016

Cause i have only one date but multible time fields plain.png


kmccool
Forum|alt.badge.img+9
  • Scholar
  • June 29, 2016

Hey Daniel,

What did you end up doing to make your multiple time fields work? I have multiple time fields then I need to calculate the duration of the work on my form.

So yea, I have the same question.

Thanks

Kassie


Forum|alt.badge.img
  • December 14, 2017

I had a situation where I needed the user to only input the time portion of the Date/Time and the customer wanted to restrict the time entry to 5 minute intervals. I though great, I'll just use the Date/Time picker, but the customer did not want the date field to be exposed. So, here's what I did.

#1. Hide the Date field in the Custom JavaScript.

NWF.FormFiller.Events.RegisterAfterReady(function () {
    document.getElementsByClassName('nf-date-picker')[0].style.visibility = 'hidden';
});

I found this would hide the date field, but left the calendar button on the form.

#2. Redefine the Date/Time picker. Added the following to the Custom JavaScript. (Note I use the empty.gif for the button).

function nfInitDatePicker() {
 NWF$(".nf-date-picker").datepicker({          
  showOn: "button",
  buttonImage: "/_layouts/15/images/empty.gif"
  buttonImageOnly: true,
  changeMonth: true,
  changeYear: true,
  showOtherMonths: true,
  selectOtherMonths: true,
  showButtonPanel: true,
  dateFormat: "m/d/yy",
  nextText: "Next",
  prevText: "Prev",
  buttonText: "",
  currentText: "Today",
  closeText: "Done",
  monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  isRTL: false,
  dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
  dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  firstDay: 0,
  onSelect: function() {
    var that = NWF$(this);
    this.fireEvent && this.fireEvent('onchange') || that.change();
    try{
      if (this.fireEvent != undefined) {
        that.change();
      }
    }
    catch(e) { };
    if (that.blur) (that.blur());
  },
  beforeShow: function(input, inst) {
  }
 });  
 var dateControls = NWF$('.nf-date-picker:disabled:visible');
 var dateControlsCount = dateControls.length;
 for (k = dateControlsCount - 1; k >= 0; k--) {                      
  NWF$(dateControls).datepicker('disable');
 }
}

#3. Remove the default control and use our new defined control. (Just added 2 lines to step #1)

NWF.FormFiller.Events.RegisterAfterReady(function () {
    document.getElementsByClassName('nf-date-picker')[0].style.visibility = 'hidden';
    nfFillerLoadFunctions.pop(); // Discard the default datepicker initializer
    nfFillerLoadFunctions.push(nfInitDatePicker); // Insert our own datepicker initializer
});

In the design the fields still appear, so placing them on the form takes a little imagination.

211577_pastedImage_2.png

But when displayed on the entry or display form, it works.

Hope this works for you.


Forum|alt.badge.img+2
  • March 22, 2018

Hi Fred,

Will it work if we have multiple controls of this type on the form? If so, what changes will i have to make, please?

regards,

Nabil


Forum|alt.badge.img+1
  • March 19, 2019
That's also my question/interest;
I wound need to only manipulate one or two of the date-time fields in the form, while leave other callendar fields intact.

Regards,
David

Forum|alt.badge.img+1
  • March 25, 2019
Upgraded ourself to Forms version 2.11.2.2 and initialization of custom datepicker does not work anymore. Has anyone found what has changed in forms, causing this nice solution not to work anymore?