$("#htxtEmoney, #htxtPoint").keypress(function(e){
var evt = window.event ? window.event : e; //for compatibility
var keyCode = evt.keyCode ? evt.keyCode : e.which;
if (keyCode == 13 || keyCode == 27 || keyCode == 8) return ; // esc, enter
if (48 <= keyCode && keyCode <= 57)
return true; // number
alert("You can write only Number.");
this.focus();
return false;
}).blur(function(e){
Payments.onChangePoint(this);
});
Here is a code I wrote.
If the user input alphabet, the alert() occur.
and then the blur() function also occur.
But I want, If an user input alphabet, the alert() occur and then the blur() function doesn’t occur at that situation.
I mean the blur() function occur only the user click other control..
sorry about my poor English. thx.
An alert shifts focus away from anything that has it, therefore automatically causing a blur. You cannot have an alert that will not cause a blur to occur.
A better solution to your problem would be to not cause an alert but rather to display a message next to or underneath your input. This will inform the user of the error and not lose focus on the input.