Jump to content
Sign in to follow this  
TroubleShooter

Styling Disabled Fields

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...