Readonly input attribute

Hello everyone, i was searching for adding readonly custom attribute to my input field. Webflow doesn’t let me to add readonly attribute cause it’s saying reserved name.

I add my script before < / body> tag and it is working well on my project.
here i wrote my script if anyone needs this you can use:

var input = document.getElementsByTagName(“input”)[0];
var att = document.createAttribute(“readonly”);
att.value = “”;
input.setAttributeNode(att);

Hey @Beril_Uysal - here’s what has worked for me…

First, set an ID for the firm field that you’d like to be readonly. We’ll use “readonly-field” as an example.

Next, use this function:

function makeReadonly() {
    document.getElementById('readonly-field').setAttribute("readonly", "");
}

You’ll then want to add a <body onload="makeReadonly"> to the custom code of the page, separate to your script snippet.

This is what’s worked for me, although there may be other solutions that I’m not aware of!

Hope it helps. :slight_smile:

1 Like