• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Date formatting and/or validation questions

Explorer ,
Jul 13, 2022 Jul 13, 2022

Copy link to clipboard

Copied

I have a few questions about dates.

1. I have a column for "Day" that appears on each row. I have the text box set as date with the custom "dd". The calendar widget works fine, but when a user types the day into the box, it gets an error if only 1-9 is entered, when it is set to "dd". Conversely, if I set it to "d" it errors when 10-31 are entered. Is there a way to have the form automatically append the leading zero when 1-9 are entered, with the field set at "dd"?  The field is named Day1, Day2, etc. With last row being Day18.

2. Is there a way to enter a date range in the single field so it displays "dd-dd"? 07-08 or 15-20?

 

Now for the nice to have just because stuff:

3. At the top of the form there are two date fields. "Month" and "Year". "Month" is a drop-down list that has no format. "Year" is a text box that has the date format with custom "yyyy". The calendar widget works on both. Is it possible to have these two fields auto populate if the calendar widget is used in one of the "Day" fields? User should still be able to manually enter info into these two fields.

 

Thanks for any help on this. I am new to this and need specific instructions and may have more questions.

TOPICS
How to , JavaScript , PDF forms

Views

360

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 13, 2022 Jul 13, 2022

1. I don't think so. The thing is that "dd" is not really a valid Date, it's just a number. You should use a different kind of Format setting for this field, but then the calendar widget won't appear... Or just use a drop-down with values from 1 to 31.

2. See #1.

Votes

Translate

Translate
Community Expert ,
Jul 13, 2022 Jul 13, 2022

Copy link to clipboard

Copied

1. I don't think so. The thing is that "dd" is not really a valid Date, it's just a number. You should use a different kind of Format setting for this field, but then the calendar widget won't appear... Or just use a drop-down with values from 1 to 31.

2. See #1.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

As for Items 1-2, I didn't care for the dropdown, so I did the following instead:

For Item 3, I found a script that I used to just place the month and year in the field at the top. I combined the Month and Year into a single Date field set at mmmm/yyyy. I set the field to Read-Only. When the user enters a date in the first date field on Row 1, it auto populates the "MonthYear" field as July-2022 for example. This works beautifully using the date picker. However, the Date1 field is set to m/d/yyyy and the other date fileds are only set m/d for typing in the date of service. I don't care for the 7/15 that has to be typed into the other fields, but I don't want the user to have to type in 7/15/2022 in every date field either. Is there a way to only display the Day (dd) part in the date fields, after a date is entered?

 

Script used in Month/Year field calculation tab:

var s = this.getField("Date1").valueAsString;
if (s=="") event.value = "";
else {
var d = util.scand("mm-dd-yyyy", s);
d.setDate(d.getDate()-0);
event.value = util.printd("mmmm/yyyy", d);
}

 

Thanks for any additional help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2022 Jul 15, 2022

Copy link to clipboard

Copied

LATEST

Never mind. After some experimenting and tweaking settings, I went with the dropdown. It does everything I need for that field. I ditched the script entirely and just used the Month/Year box up top formatted as mmmm/yyyy. Simpler and less typing. Thanks again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines