Configuring the datepicker

keithlyon
Kilo Contributor

I am very new to ServiceNow. We are trying to limit the ability to enter dates in a field to the datepicker only. I have referenced the doc -

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/time/task/t_ConfigureD...

and confirmed that the property is configured to true (we are on Helsinki). However dates still can be typed into the datepicker. I'm sure there is something easy I need to do to the field or form to enable this, but I am unable to find anything anywhere. Any help would be appreciated.

Thanks,

Keith

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi Keith,
You can easily achieve this via an onLoad Client Script. See below,   just replace 'field_name' with the actual name of your date or date/time field.


  1. function onLoad() {  
  2.   // Sets the field's background to a gray, making is appear read-only.  
  3.   g_form.getControl('field_name').className='disabled';  
  4.   // Sets the field read-only  
  5.   g_form.getControl('field_name').readOnly=true;  
  6. }  


Please mark this response as correct and helpful via your post link (Configuring the datepicker ) to help others with the same question.



Thanks,


Robbie


View solution in original post

7 REPLIES 7

Robbie
Kilo Patron
Kilo Patron

Hi Keith, apologies - just seen this. I'll take a look and check for you.



Cheers,


Robbie


keithlyon
Kilo Contributor

No worries and it turns out there is customization within our instance which is causing this to not work correctly. It works fine when I apply it to other date fields. We are looking into the conflicting script to determine if we can modify around it.


Robbie
Kilo Patron
Kilo Patron

Great, I'm glad its resolved.


Cheers, Robbie.