Expand my Community achievements bar.

How can I remove dropdown calendar menu from date/time field.

Avatar

Former Community Member
I set up a javascript calculation based on the input of a date field. As long as the user enters the date manually the script works fine. If user attempts to select date by drop down menu then script will not work. How can I remove the calendar feature from the Date field?
4 Replies

Avatar

Level 5
Simply use TextField inplace of Date/Time field.

Avatar

Former Community Member
Javascript unable to calculate after switching over to text field. Also unable to set proper display and edit patterns field is converted to text format

Avatar

Level 5
You may have to wire custom script to get you what you need. That would probably work on 'exit' event.



Just you give you better Idea here is some thing I have on a date field. If user types his own date instead of picking from calendar this code checks whether it is valid date or not and returns to the same field either they enter valid date or clear the field.



This is FormCalc script. You may get the idea how this works and make it work for you using the same logic either in FormCalc or JavaScript.



----- form1.SOF.Head.Table1.Row1.ReqDate.Date_ReqDate::exit: - (FormCalc, client) ------------------



if (HasValue($)) then

if (Len($.rawValue) == 10) then

var S1

var MM

var DD

var YYYY

var Derror

var D1

var D2

var S2

Derror = 0

D1 = 0

D2 = 0

S1 = $.rawValue

D1 = At(S1, "-")

S2 = Right(S1, 5)

D2 = At(S2, "-")

if (D1 > 0 and D2 > 0) then

if (D1 == 3 and D2 == 1) then

MM = Substr(S1, 1, 2)

DD = Substr(S1, 4, 2)

YYYY = Substr(S1, 7, 4)

elseif (D1 == 5 and D2 == 3) then

MM = Substr(S1, 6, 2)

DD = Substr(S1, 9, 2)

YYYY = Substr(S1, 1, 4)

else

Derror = Derror + 1

endif

else

Derror = Derror + 1

endif

if (Oneof(MM, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12")) then

Derror = Derror

else

Derror = Derror +1

endif

//xfa.host.messageBox("MM"+ Derror, "Incorrect Date", 1, 0)

if ((Oneof(DD, "01", "02", "03", "04", "05", "06", "07", "08", "09")) or ((DD >=10) and (DD <= 31))) then

Derror = Derror

else

Derror = Derror + 1

endif

//xfa.host.messageBox("DD"+ Derror, "Incorrect Date", 1, 0)

if ((YYYY >= 1975) and (YYYY <= 2050)) then

Derror = Derror

else

Derror = Derror + 1

endif

//xfa.host.messageBox("YYYY"+ Derror, "Incorrect Date", 1, 0)

if (Derror > 0) then

xfa.host.messageBox("Preferred valied date between Jan 01, 1975 and Dec 31, 2050. ", "Incorrect Date", 1, 0)

xfa.host.setFocus($.somExpression)

else

//good

$.formattedValue = Format("MMM DD, YYYY", Concat(YYYY, MM, DD))

if ($event.shift) then

//xfa.host.messageBox("Shift")

var sh

sh = 1

//xfa.host.setFocus("xfa.form.form1.SOF.Head.RadioAttachTo.RadioAttachTo3")

else

if (xfa.event.commitKey == 1) then

var A

A = 1

else

xfa.host.setFocus("xfa.form.form1.SOF.Head.Table1.Row2.CustName")

endif

endif



endif

else

xfa.host.messageBox("Preferred valied date in format MMM DD, YYYY.", "Incorrect Format", 1, 0)

xfa.host.setFocus($.somExpression)

endif



endif



Good luck,

SekharN

Avatar

Former Community Member
Fixed issue by changing field from Date/Time to Text Format. My Display, edit and binding patterns changed from MM/DD/YYYY to 99'/'99'/'9999. The auto date to age calculation (javascript) that was provided to me online still works with this format.