- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 09:46 AM
I have a date field which I want to restrict users from manually entering the values instead only use the calendar icon to pick. Is this possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 11:38 AM
Another approach is to use a UI Policy with Run scripts and On load checked, and Isolate script unchecked. Use a script like this in the Execute if true box
function onCondition() {
var $ = this.jQuery;
$('input[id="table_name.field.name"]').attr('readonly', true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 10:19 AM
You could use a script like this with your field name:
function onLoad() {
// Sets the field's background to a gray, making is appear read-only.
g_form.getControl('field_name').className='disabled';
// Sets the field read-only
g_form.getControl('field_name').readOnly=true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 10:41 AM
Brad, I was about to suggest the same solution, but I noted that the g_form.getControl does not work in Service Portal. I was able to get your script to work on native UI, but not within Service Portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 11:21 AM
I tried it but did not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2025 11:24 AM
Is this a field on a form, or a variable on a Catalog Item? Are you using the native UI, or Service Portal?