Preventing focus on next form element after showing alert using JQuery
Posted
by digitalsanctum
on Stack Overflow
See other posts from Stack Overflow
or by digitalsanctum
Published on 2010-03-24T02:14:32Z
Indexed on
2010/03/24
2:23 UTC
Read the original article
Hit count: 302
I have some text inputs which I'm validating when a user tabs to the next one. I would like the focus to stay on a problematic input after showing an alert. I can't seem to nail down the correct syntax to have JQuery do this. Instead the following code shows the alert then focuses on the next text input. How can I prevent tabbing to the next element after showing an alert?
$('input.IosOverrideTextBox').bind({
blur: function(e) {
var val = $(this).val();
if (val.length == 0) return;
var pval = parseTicks(val);
if (isNaN(pval) || pval == 0.0) {
alert("Invalid override: " + val);
return false;
}
},
focus: function() {
$(this).select();
}
});
© Stack Overflow or respective owner