Page 1 of 2
DateTime Fields
Posted: 24 Nov 2014
by SpongeBen SquareJaw
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.
Re: DateTime Fields
Posted: 25 Nov 2014
by Dmitry Kozlov
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')}" />
Re: DateTime Fields
Posted: 25 Nov 2014
by SpongeBen SquareJaw
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.
Re: DateTime Fields
Posted: 26 Nov 2014
by SpongeBen SquareJaw
Is there a way for this to except empty or Null values?
Re: DateTime Fields
Posted: 27 Nov 2014
by Dmitry Kozlov
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;
});
Re: DateTime Fields
Posted: 03 Dec 2014
by SpongeBen SquareJaw
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.
Re: DateTime Fields
Posted: 04 Dec 2014
by Dmitry Kozlov
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.
Re: DateTime Fields
Posted: 04 Dec 2014
by Dan_C
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?
Re: DateTime Fields
Posted: 04 Dec 2014
by Dmitry Kozlov
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.
Re: DateTime Fields
Posted: 04 Dec 2014
by Dmitry Kozlov
Also you can store your date and time in a plain text field especially if you set it automatically via JavaScript.