TroubleShooter Posted April 3, 2019 Report Share Posted April 3, 2019 Hi, Is it possible to style disabled fields on a Web Form? I've been trying to look at styles and it seems that there is no option to style/format a disabled element field. A disabled element seems to look the same as an active one. I was hoping I can do some styling to make it stand-out or imply to the users that certain elements on the web form are disabled (commonly due to rules restriction). Hope someone can help. TIA -TroubleShooter Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted April 3, 2019 Report Share Posted April 3, 2019 Hello TroubleShooter, It is possible with a little help from our friend, JavaScript. Just paste this code snippet to your Footer (HTML Editor should be disabled from the Advanced Tab (as usual)) <script> var frm = document.querySelector(`[action*="[@cbAppKey]" `); frm.addEventListener('DOMSubtreeModified', function() { frm.querySelectorAll('input').forEach( function(elem) { if (elem.disabled == true) elem.parentNode.parentNode.parentNode.classList.add("elem-disabled") else elem.parentNode.parentNode.parentNode.classList.remove("elem-disabled") }); }) var event = new Event("DOMSubtreeModified"); frm.dispatchEvent(event); </script> What this does is, it adds/removes the class of "" to the table row (<tr>) of the disabled element. This enables us to target specific fields related to disabled elements via CSS. To style your elements, you may use the following CSS Rules to be pasted on your DataPage Header (HTML Editor should be disabled from the Advanced Tab (as usual)) <style> /* .elem-disabled row itself */ .elem-disabled { background: green !important; } /* label child elements of .elem-disabled */ .elem-disabled label { color: blue !important; } /* td elements of .elem-disabled */ .elem-disabled td { color: red !important; } /* All child elements of .elem-disabled */ .elem-disabled * { color: yellow !important; } </style> Hope this helps. Happy Hacking! DN31337 Quote Link to comment Share on other sites More sharing options...
autonumber Posted October 3, 2023 Report Share Posted October 3, 2023 Hi! Just to update this post, you can also style the disabled fields using CSS. Add the code below to the header section. <style> #InsertRecordLast_Name:disabled { background-color: gray; opacity: 0.3; } </style> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.