rmk
asked on
blur regex
I'm trying to make sure that the contents of a text box can only be a poistive or negative integer. If not I want to send the focus back to that textbox.
What's wrong with this jquery code which executes for several textboxes? It is allowing non integer values and it sets the focus to the next contron instead of the control with the problem.
$(document).ready(function () {
$(".EOWDPRCYQTextBox").blu r(function (event) {
if (this.value.match(/[+,-]{0 ,1}[0-9]{1 ,6}/) == null) {
alert("bad");
this.focus;
}
}) // blur
}); // ready
What's wrong with this jquery code which executes for several textboxes? It is allowing non integer values and it sets the focus to the next contron instead of the control with the problem.
$(document).ready(function
$(".EOWDPRCYQTextBox").blu
if (this.value.match(/[+,-]{0
alert("bad");
this.focus;
}
}) // blur
}); // ready
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It is quite dangerous to blur, alert, and focus in the same code. Try pasting a wrong value into a field and then click another field. You should use setTimeout to focus so the alert does not trigger the blur of the next field
ASKER
I am very new to jquery. Can I ask you to modify my code to properly include the setTimeout?
If it works for you then perhaps
No needd to change. Just be aware that the issue exists
No needd to change. Just be aware that the issue exists
ASKER
solved it myself
ASKER
$(document).ready(function
$(".EOWDPRCYQTextBox").blu
if (this.value.toString().mat
alert("bad");
this.focus;
}
}) // blur
}); // ready
But I still can't get the focus to stay on the same control. How do I do that?