I am developing some web interfae, I would like to convert some INPUT elements in non-editable/non-changable but still showing the inputed value. How an be this done?
In Chrome at least, disabled attribute makes the inputed value disappear (unmarked checkboxes, non-filled radio buttons) but readonly label allows user to keep changing values. Why? Is this a Chrome thing? Whats the best wa for simply not-allowing interaction but mantaining and showing the preselected value so far?
EDIT: I am using jQuery´s
$('#deForm :input').attr('readonly',true);
and
$('#deForm :input').attr('disabled',true);
for this test. Both seem to be handled ok, since GUI shadows input elements. But none of them shows my expected functionality
EDIT2: I also tried to put ‘readonly’ and ‘disabled’ as the second argument in jQuery instead of ‘true’ but it has same effect
EDIT3: I also tried to add to readonly.
$('#deForm :input').attr('readonly',true);
$('#deForm :input').keypress(function(event){
event.preventDefault();
});
but behavior is the same as in plain readonly
This is the default behavior of the
readonlyanddisabledproperties. You can use thepreventDefaultmethod of the event object.http://jsfiddle.net/2fKjX/