Reputation: 81
I am building my own context menu and am replacing copy / cut / paste functionality. I have copy and paste working but I cannot paste arbitrary text into an input of type 'number'.
I am setting the value using javascript similiar to below
document.getElementById('input').value = 'some text';
Whenever type is of number, the text is lost and the input is left blank.
Can I set the input to a string? The system paste allows this, but the input seems to parse the input and fail.
Upvotes: 0
Views: 93
Reputation: 8586
You can change
<input id="input" type="number" value="1"></input>
to
<input id="input" type="text" value="1"></input>
Or change it in your javascript by adding
document.getElementById('input').setAttribute('type','text')
in your setText()
function
jsFiddle: Here is the resulting jsFiddle
Upvotes: 2