"Mark Thomas" <mr*@thomaszone.com> wrote in message
news:a0**************************@posting.google.c om...
I need to get text pasted into a form field at the time it was pasted.
The value of the field is still blank in the onpaste handler. The
onchange event is not triggered until the input loses focus, and I
want to execute a function before that happens. How can I do that?
Use onpaste (IE only as far as I am aware):
<input type="text" onpaste="fnPaste(this)">
<script etc.>
function fnPaste(el){
event.returnValue=false;
// stops default action
a=window.clipboardData.getData('Text');
// what they think they were about to paste
el.value = a.replace(/ /g,'_');
// or whatever you would like to do
}
</script>