Search code examples
dynamics-crmcrmdynamics-crm-4

Hide the date part on a DateTime field


I would like to have a time-only field on my CRM form. As it is apparently not possible, I plan to use a DateTime field and hide the date part (circled in red on the following image).

enter image description here

How can I hide the date part on a DateTime field using Javascript ?


Solution

  • Found it:

    // Set the date in order to be able to modify the time
    document.getElementById("field_name").DataValue = new Date(2000, 1, 1);
    // Hide the date part
    document.getElementById("field_name").childNodes[0].childNodes[0].style.display =
        "none";
    document.getElementById("field_name").childNodes[0].childNodes[1].style.display =
        "none";