instead of example:
$(".myfield").blur(function() {
// validate
})
$(".myfield").keyup(function() {
// validate
})
is there a way to combine these two?
instead of example:
$(".myfield").blur(function() {
// validate
})
$(".myfield").keyup(function() {
// validate
})
is there a way to combine these two?
Yes
$(".myfield").bind('blur keyup', function(){
// validate
});
Reference: .bind()
In case you want to validate each for itself...
$('.myfield').live('blur keyup', function(event) {
if (event.type == 'blur') {
// validate on blur
}
if (event.type == 'keyup') {
// validate on keyup
}
});
use with .on() Event
$(document).on("keyup blur", "#myfield", function(event)
{
// your code
});