Reputation: 3921
I want to make an input field that has a min-width of 25px and a width of 10px per entered character. Therefore, each character entered after the second will increase the width of the input field. Lastly, the input field should become smaller when characters are deleted.
I just need an idea of how to solve the variable width based on input characters. Suggestions?
Thanks!
Upvotes: 1
Views: 812
Reputation: 324790
This is trivial.
<input type="text" style="width: 25px;"
onKeyUp="this.style.width = Math.max(25,this.value.length*10)+'px';" />
Upvotes: 3