How to Remove Readonly Attribute From an Input Field on Focus

1 year ago admin Html

In this lesson, we will see how to remove the read-only attribute from the HTML input field on focus, as you know the read-only input field cannot be modified and in some cases, we want to remove the attribute when the input field is on focus.


Remove the read-only attribute

To do that, check the code below:

                                                    
                                                                                                                
<input type="email" id="email" name="email" class="form-control" readonly onfocus="this.removeAttribute('readonly');"/>