Javascript disabled change form field or button properties
HTML button has a disabled attribute, which is used to disable the function of the button. In addition to controlling the button button, the disabled attribute can also control the use of other block functions, such as text input boxes, option buttons, or drop-down menus. For items, generally speaking, you can preset the field status when the webpage is opened, for example, it is disabled at the beginning, only the form fields are displayed, or the default is to fill in data, but when the webpage is opened, how to change the disabled attribute What? Through JavaScript can do.
Javascript disabled change form field example
function ChangeDisabled(value){
if(value=='1'){
document.getElementById('TetstText').disabled=false; // Change the field to be available
}else{
document.getElementById ('TetstText').disabled=true; // Change the field to be disabled
}
}
</script>
<input type="text" id="TetstText">
<input type="button" value='Change the field to Available' onclick="ChangeDisabled(1)">
<input type="button" value='Change the field to disabled' onclick="ChangeDisabled(2)">
Post a Comment
0 Comments