+1  A: 
jAlert("There is an error", "error", function() {
   Do some thing afteruser click on OK
   .....
   Some code behind
});
Jakub Konecki
that really took some effort GOOD one :)
jknair
Thank you Jakub, i commented the below answer as the reply box is too short to post
tlpd
A: 

Thank you Jakub for your answer and i am sorry i did not clarify my situation well enough. In real, i got the below code logic to validate the inputed data on keypress event.


if(config.maxlength compare to $(this).val().length){
    jAlert("There is an error");
    $(this).focus();
    event.stopPropagation();
    return;
}
$hidden.attr('value', $(this).val());

As the above content, the jAlert did not wait for user to click on OK button and just call [$(this).focus();], so the cursor is in the parent control and user can not click on OK button on the box.

If i use the default alert box in this case, it will wait user click on OK button then focus back to the validating control

As i am customizing an old system, so behind $hidden.attr('value', $(this).val()); i got a lot of other logic and sub-logic. If i have to use if condition like that, i think i could not control all the source code. So i wonder if existing a solution for this?

tlpd
You should edit you question instead of adding an answer. Could you post an actual code - the example above doesn't use the callback for jAlert...
Jakub Konecki
Sorry, problem solved as your way. It was my mistake. Thank you again
tlpd