kvnmck18 Posted October 2, 2006 Share Posted October 2, 2006 How do you "lock" and input field in a form? So it can't be edited, but you can see the intial/default value. Link to comment Share on other sites More sharing options...
aspnetguy Posted October 2, 2006 Share Posted October 2, 2006 you can do this <input type="text" readonly="readonly".../> or use JSvar field = document.getElementById('fieldId');field.disabled = true;The JS method will "gray out" the field similar to Windows Forms. Link to comment Share on other sites More sharing options...
hiall Posted October 3, 2006 Share Posted October 3, 2006 (A little clarification below.)You can either use the readonly attribute or the disabled attribute:<input type="text" readonly="readonly" ...<input type="text" disabled="disabled" ...The difference is that the disabled attribute will gray out the text field while the readonly attribute will not. On Firefox, the text in a disabled text field cannot be selected and copied to the clipboard.You can also use JavaScript to set the readonly or disabled attribute:var field = document.getElementById('fieldId');field.readOnly = true;var field = document.getElementById('fieldId');field.disabled = true; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now