JavaScript Read Only

Revision as of 09:27, 11 April 2012 by Philip Lacey (talk | contribs)
Revision as of 09:27, 11 April 2012 by Philip Lacey (talk | contribs)

readOnly is a lovely way of protecting your customer data in a database where some data is preloaded.


document.getElementById("fieldnameHere").readOnly=true;


When you have data loaded into a database, the customers data will generally be presented to an agent / user. You may not want them editing particular details like a customer Id or reference details.


Simple put a readOnly statement into the onLoad event of the database and those fields will not be editable by the user.


Do NOT use the disabled command as this will cause those fields to be wiped. This is a common mistake in JavaScript coding, where database updates are involved.