DateTime Fields

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
SpongeBen SquareJaw
Posts: 16
Joined: Mon Nov 24, 2014

24 Nov 2014

Is there a way to get the minutes in the date time fields to enter by actual minute, not just increments of 5.

I would even take entering value through java or jquery on forms.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

25 Nov 2014

Hello,

Yes, you can replace the default date and time control with simple input field following way:
1. Remove Date&Time field from your Edit form
2. Put HTML-control
3. Set CDATA property to False
4. Set Content to:
<asp:TextBox ID="DateTimeTextBox" runat="server" Text="{ddwrt:FormatDateTime(string(@DateTime), 1033, 'g')}" __designer:bind="{ddwrt:DataBind('u','DateTimeTextBox','Text','Load','ID',ddwrt:EscapeDelims(string(@ID)),'@DateTime')}" />
5. Replace the highlighted text with the internal name of your date & time field.
6. Save the form.
PS: HTML-content for the New form:

<asp:TextBox ID="DateTimeTextBox" runat="server" Text="{ddwrt:FormatDateTime(string(@DateTime), 1033, 'g')}" __designer:bind="{ddwrt:DataBind('i','DateTimeTextBox','Text','Load','ID',ddwrt:EscapeDelims(string(@ID)),'@DateTime')}" />

SpongeBen SquareJaw
Posts: 16
Joined: Mon Nov 24, 2014

25 Nov 2014

Thanks this works but it errors when I have no value. This field is set to allow blank values. I'm guessing it is a format error since it is formatting a blank value.

SpongeBen SquareJaw
Posts: 16
Joined: Mon Nov 24, 2014

26 Nov 2014

Is there a way for this to except empty or Null values?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

27 Nov 2014

You can assign a default value to the textbox if it's empty right before the submission with the help of JavaScript. First, assign a CSS class to your textbox:

<asp:TextBox ID="DateTimeTextBox" runat="server" CssClass="date-time-textbox" Text="{ddwrt:FormatDateTime(string(@DateTime), 1033, 'g')}" __designer:bind="{ddwrt:DataBind('u','DateTimeTextBox','Text','Load','ID',ddwrt:EscapeDelims(string(@ID)),'@DateTime')}" />

Next, put the following code into JS-editor:

Code: Select all

fd.onsubmit(function() {
	if (!$('.date-time-textbox').val().trim()) {
		$('.date-time-textbox').val('01/01/2014 12:00 AM');
	}
	return true;
});

SpongeBen SquareJaw
Posts: 16
Joined: Mon Nov 24, 2014

03 Dec 2014

This will not work because we leave this date blank until a process is complete. So it has to be able to be blank from initial insert and updates. Putting in a date is not going to work for my needs.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Dec 2014

So you can create a separate form containing the date and time field and display it only when the process is completed with the help of groups functionality. Other forms will not contain this field.

Or you can clear the default value of the date and time field with the help of JavaScript on initial form loading and set its value back right before the submission.

Dan_C
Posts: 63
Joined: Tue Dec 02, 2014

04 Dec 2014

This is a problem for me as well.

I'm trying to update various DateTime fields to record when a user presses a button. I want to record the exact time... not five minute increments. I also don't want a default time either because I want a time there only if the user presses the button.

Why is there a five minute increment limitation? Is there not a way in SP Forms to update a DateTime field with the exact time OnClick?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Dec 2014

This is SharePoint limitation. Forms Designer just rearranges out-of-the-box controls. I've suggested an option that is quite easy to implement. But you can still develop a custom field and add it to your list. Forms Designer supports custom fields.

Our support team can help you with this task, just send the detailed requirements to support@spform.com and they will estimate them.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Dec 2014

Also you can store your date and time in a plain text field especially if you set it automatically via JavaScript.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests