i want to protect my inputs from brut force hacks
so i made some validations for my inputs .. and i want them to work on focus event and
focusout event too ! is there any elegant way to do it, other than this :
$(this).focus(function(){
// excute my code
});
and then
$(this).focusout(function(){
// excute the same code !
});
i want do this for too many inputs .. and i don’t want do the same work twice for (focus, and focusout) to avoid the extra load of the page !
While I disagree with the premise of this question (you can’t prevent brute-force attacks via client-side code) you can simplify your code by passing both events as a space separated string to
on:Here’s the fiddle: http://jsfiddle.net/bL79F/
If you’re using an older version of jQuery, use
bindinstead:Here’s the fiddle: http://jsfiddle.net/bL79F/1/