-2

I need to overwrite the value in the textbox.

I have a form and for some reason I need to completely overwrite the value in the text box. For example, the text box with id 'city' and the default value is 'Mumbai'.

<input type="text" id="city" value="Mumbai">

But if the user changes it to some other city, it should completely overwrite or select the whole word thouroughly, without having to press backspace for 6 characters.

[https://stackoverflow.com/questions/10761508/change-html-textbox-overwrite-instead-of-insert-as-user-types][1]

The above link shows overwriting in text box. I want to delete the whole value in one go.

Prachi
  • 3
  • 4

1 Answers1

2

Use javascript select function in onClick event.

<input type="text" onClick="this.select();" id="city" value="Mumbai">