Disable A Input Field So "getelementbyid(field_name).value =" Will No Longer Change Its Value
I have an input field which is disabled or not based on its contents. However I also have a button which changes the value of this field using the javascript getElementById('field
Solution 1:
The simplest way is probably to perform the check in your button's click
handler.
Instead of doing:
document.getElementById("field_name").value = "something";
Do:
var element = document.getElementById("field_name");
if (!element.disabled) {
element.value = "something";
}
Solution 2:
If you want to have the setting code to respect the disabled
attribute, simply make it so:
var el = getElementById('field_name');
if (!el.disabled) el.value = "something";
Solution 3:
Try something like this-
if(!getElementById(field_name).disabled){
getElementById(field_name).value = "something";
}
Post a Comment for "Disable A Input Field So "getelementbyid(field_name).value =" Will No Longer Change Its Value"