I need to add an event to a text box without modifying the input tag itself. I created a function which will check to make sure only letters are entered and not allow numbers or symbols. I have to code for this and it is functional... when ins开发者_StackOverflow社区erted inside of the input tag, I am having trouble in adding this event elsewhere in my code. Any help is much appreciated.
Thanks in advance,
Get all the inputs that you are interested in monitoring. Then subscribe each of them to a function and your event.
QuirksMode talks about traditional event mapping here and also has links to W3C standard events.
So gather all your inputs and then attach your event to them
Pseudocode:
var elementArray = getAllInputElements();
for (var element in elementArray) {
element.onclick = myfunction;
}
精彩评论