Reputation: 307
i'm using on HTML input fields the onblurevent to validate input directy after leaving the field. In the eventhandler look after the id of source element and call validation methods:
<input id="ex1" onblur="app.checkInput(event);" />
<input id="ex2" onblur="app.checkInput(event);" />
my JS-validation:
this.checkInput = function(event) {
var result;
if (event.srcElement.id == 'ex1') {
result = this.validateEx1();
}
else if ( event.srcElement.id == 'ex2') {
result = this.validateEx12();
} //...
This works fine in IE and Chrome, but the event parameter has in Firefox no Field 'srcElement'. Is there a way to make it compatible for all browsers?
Thanks for your help in advance.
Upvotes: 0
Views: 129
Reputation: 22158
Try with standards.
You can use target
or currentTarget
event.currentTarget.id;
More info:
https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget
Upvotes: 2