Say I have an input field "lastname", but I do not want people to insert something if the field "firstname" is still empty. Example: http://jsfiddle.net/GQyHp/
$('input[name=lastname]').focus(function() {
if (!$('input[name=firstname]').val()) {
alert('First enter your first name');
$(this).blur();
}
});
If I click on the "lastname" field, I will get a popup, but after I click "OK", it will launch this popup again. If I delete blur(), there is no second popup.
How can I prevent this function from starting with a function blur()?
source
share