JQuery Input box focus problem

Anvesh picture Anvesh · Mar 31, 2011 · Viewed 10.5k times · Source

I want to check some condition on blur of input box in jQuery. Once I lose focus from Input box I am not able to get focus again to that box.

Code:

if ($("#Amount").val() < 10000) { 
    alert('The minimum amount is $10,000.'); 
    $("#Amount").focus();
} 
else {
}

Once i lose focus from $("#Amount") it's not setting focus to that control.

Thanks in advance.

Answer

Levi Morrison picture Levi Morrison · Mar 31, 2011

Well, this is what you are looking for, I believe: http://jsfiddle.net/6Seks/5/

Edit: just noticed how close my answer is to Scroobler's post, though mine doesn't suffer the larger than 10000 bug his does.