How to make a field uneditable?


#1

Is there a way to make a field impossible to edit? Possible with the addition of some javascript?


#2

Hi @Andy2 you can disable a field using the following javascript (remember to wrap the code in script tags):

document.getElementById('FIELD ID HERE').disabled = true;

Could you let me know a bit more about your use-case for disabling a field? The above code will make it impossible to type in or change a field. If you’re looking to make sure a certain value in a form field stays intact a hidden field might be a more suitable option for you.


#3

Hi Rob, thanks for the reply but I found a very simple workaround solution, which was just to place a see-through box over the field that I didn’t want to be editable. But thanks for this, this type of code is what I had in mind when I first posted here!


#4

My pleasure @Andy2 happy to help! I like your solution a lot actually. Really simple and easy to implement, especially if you’re working with others on the page and don’t want to mess with code :slight_smile: