Track input field text and run function on the fly?
Hi,
How can I track what is written to an input field on the fly(event that is not "click" "hover" etc but something like "track" or "observe")?
Lets say I have a js object like this:
- var array1 = {id1: 'keyword', id2: 'execute', id3: 'go'};
And 3 input fields like this:
- <input id"id1" name="id1"></input>
<input id"id2" name="id2"></input>
<input id"id3" name="id3"></input>
I want to track the input fields so that
- if(
the string "keyword" is written to the id1 field
the string "execute" is written to the id2 field
the string "go" is written to the id3 field
){ something happens on the fly without any refresh or blur or press of a submit button};
Something like this(does not work...):
- //tracks all input fields
$('input').live("track", function(){
- //If the string that is defined in the array is written to the input field
- if (this.val == array1[this.id]) { //Should i use "val" here..?
//do something:
thefunctioniwanttorun();
}
});
Thanks for all answers!