How can we make an input field readonly? There is an option to make a field readonly in Page Editor, however it translates the field in HTML text instead of making the HTML input box readonly. I am tring to make the following: I need this for a dynamic form.
You can use client-side script:
theForm.myField.disabled=true;
I have the same question about of making readonly fields,
if i use theForm.myField.disabled=true; the value will not be save.
To send data back to browser you'll need tag.
I was able to achieve what you looking to do using this trick:
In the object definition, you specify a JavaScript Event Handlers for the field you want the behave as readonly.
Enter the following in the onfocus handler :
onfocus = " this.readOnly=true; this.blur(); "
It would be nice to have this trick integrated as a new build-in feature.
Hi
Another way to go about this is to set readonly when the page loads.
onload property of the page:
document.theForm.fieldName.readOnly = true;
as per experience some browsers reject the code above so we use:
document.theForm.fieldName.readOnly = 'readonly';
You can apply both if need be. Just to be sure that the field is set to readonly. Additionally using readonly will still save the data within the field unlike disabled.
Hope this helps
Piscoso, Martin
Rollbase