- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 08:13 PM
How to make a field readonly onloading on a ui page
Source<input type="text" id="selectDesc" readonly="true"></input>
tried this but not working
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 09:15 PM
Hi,
you can make it like this
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<body onload="makeReadonly()">
Source<input type="text" id="selectDesc" readonly="true"></input>
</body>
</html>
</j:jelly>
Client Script:
function makeReadonly(){
var a= document.getElementById('selectDesc');
a.setAttribute('disabled','true');
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 09:07 PM
You can't type anything if you make readonly="true". The above statement will work, but it still shows like a normal text box.
You need to use the below statement to completely make it as readonly.
<input type="text" id="selectDesc" disabled="true"></input>
Readonly (You can't type anything, but it still shows as normal textbox)
Disabled
Please mark it as correct answer if it helps.
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 09:15 PM
Hi,
you can make it like this
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<body onload="makeReadonly()">
Source<input type="text" id="selectDesc" readonly="true"></input>
</body>
</html>
</j:jelly>
Client Script:
function makeReadonly(){
var a= document.getElementById('selectDesc');
a.setAttribute('disabled','true');
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader