views:

32

answers:

4

hi

i want to know get text box value when i type the value by every press.

i have to get the value.

if i type numbers i have to get. so i have checking with that value.

thanks in advance

A: 

Probably you will have to serve events on input field: onkeypress, onkeyup, onkeydown, onpaste, onchange.

gertas
there is also `oninput` which does exactly what you want in all browsers but not MSIE (<=8.0)
gertas
@gertas: `onpropertychange` in IE is as good as `oninput`, you just need to check `event.propertyName == "value"`.
Andy E
A: 

html:

<input type='text' id='my_input' />​​​​​​​​​​​​​​​​​​​​​​​​​​​​

javascript:

var my_input = document.getElementById('my_input');
my_input.onkeyup = function() {
    alert(my_input.value);
}​​​​​​
sje397
A: 

You can get the value of an input element from its value property, e.g.

element.value

To execute some function on every key press, you should bind an event handler for the keyup event to this element.

You should make yourself familiar with event handling in JavaScript and the variations in the different browsers. The site I linked to (quirksmode.org) is a very good resource for that.

Felix Kling
A: 

One thing to note is that in certain browsers the method by which you get the value of a textarea differs. I'm thinking in IE6, at least, it actually registers the value of a textarea as it's innerHTML (or the other way around).

Worth doing a check in you eventListener for if the value is set, or not, and checking the innerHTML if it's not, just in case!

Alex