css diable text edit code example

Example 1: freeze input text css

pointer-events: none;

Example 2: freeze input text css

/*
You can't disable anything with CSS, that's a functional-issue. 
CSS is meant for design-issues. You could give the impression of 
a textbox being disabled, by setting washed-out colors on it.

To actually disable the element, you should use the disabled boolean 
attribute: http://jsfiddle.net/p6rja/
*/
 <input type="text" name="lname" disabled />
 /*Or, if you like, you can set this via JavaScript: 
  http://jsfiddle.net/655Su/ */
  document.forms['formName']['inputName'].disabled = true;
/*exp */
<form name="fish">
    <input type="text" name="big" value="Big Fish" >
    <input type="text" name="little" value="Little Fish" >
    <input type="text" name="tiny" value="Tiny Fish" >
</form>
<script>
      document.forms['fish']['big'].disabled = true;
</script>
/*
Keep in mind that disabled inputs won't pass their values through 
when you post data back to the server. If you want to hold the data,
but disallow to directly edit it, you may be interested in setting
it to readonly instead. Demo: http://jsfiddle.net/655Su/1/
 */
/* Similar to <input value="Read-only" readonly>*/
document.forms['formName']['inputName'].readOnly = true;
/*
This doesn't change the UI of the element, 
so you would need to do that yourself:
*/
input[readonly] { 
    background: #CCC; 
    color: #333; 
    border: 1px solid #666 
}
/* You could also target any disabled element: */
input[disabled] { 
  /* styles */ 
	pointer-events: none; 
}

/* https://stackoverflow.com/questions/2458595/disable-a-textbox-using-css */

Tags:

Html Example