The CreatorCon Call for Content is officially open! Get started here.

remove date format mm/dd/yyyy from UI Page when using <g:ui_input_field type="date"

clyon
Tera Guru

I have created a UI Page where I am using <g:ui_input_field type="date"

find_real_file.png

If there is no value it displays 'mm/dd/yyyy' on my page. How can I get rid of this?

find_real_file.png

9 REPLIES 9

Chuck Tomasi
Tera Patron

Hi Christina,



Have you looked at using the built in macro for dates?



<g:ui_date />



Attribute information can be found in the macro. Substitute your instance name for YOURINSTANCE in the URL below.



https://YOURINSTANCE.service-now.com/nav_to.do?uri=sys_ui_macro.do?sys_id=c5f3ea3cc0a8016500fa6a3049...


Below is the ui_date when there is a value and when there isn't. It does get rid of the 'mm/dd/yyyy' but b/c my UI page is all read only it brings up formatting issues for the page.


Is there anything else I can do to display a date value in the correct format (without the 'mm/dd/yyyy' if there is no value)?



Hi christina,



  Use onfocus and onfocusout to change the input types.Try this



<g:ui_input_field label="Date" name="date" value="{loaninfo.u_cert_date}" type="text" onfocus="(this.type='date')" onfocusout="(this.type='text')" readonly="true"/>


Your solution did remove the 'mm/dd/yyyy' that is present when <g:ui_input_field type="date" . But with that it also changed my date format when there is a value back to yyyy-mm-dd, instead of mm/dd/yyyy.


Might there be any other solution so that when there is a value it is in the correct date format and when there is no value, it's blank?


An if statement to check the value??



Thanks!