How to Show/hide date field in a UI page (g:ui_date_time)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2020 04:22 AM
I have a UI page with date time field as below:
<div class="form-group is-required row">
<label for="apt_date" class="control-label col-sm-3" style="text-align:right" id="aptdate_label">
<span class="required-marker"></span>${gs.getMessage('Appointment Date')}
</label>
<span class="col-sm-9">
<g:ui_date_time name="apt_date" query="" id="apt_date" style="width:180px"/>
</span>
</div>
On form load I would like to hide this date field. I have tried the below code and its not working
document.getElementById('apt_date').style.display = "none";

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 12:20 PM
Hi,
Use this field as below
<g:ui_date_time name="apt_date" query="" id="apt_date" name="apt_date" style="width:180px"/>
Then it will work.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 02:08 PM
Hi Ashutosh,
You can see on my original post that has the Name tag.
If you want to hide a reference field you use the below code where sys_dispaly will hide the text box and lookup will hide the search button:
document.getElementById('sys_display.vendor_name').style.display = "none";
document.getElementById('lookup.vendor_name').style.display = "none";
So my requirement is to hide a ui_date_time field and looking for script to do that .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 11:41 PM
Hi,
Wrap it under an div and hide the whole div then as below:
<div id="something">
<span class="col-sm-9">
<g:ui_date_time name="apt_date" query="" id="apt_date" style="width:180px"/>
</span>
</div>
document.getElementById('something').style.visibility = "none";
Thanks,
Ashutosh