I'm checking the value of a form field and if the value is more than 5 an alert box pops up. This works, but I've noticed that if I fill in the field 1 time, the alert box can be closed normally. If I then enter a new value, also above 5, I need to close the alert box two times, and three times if I would enter a third value. And so on...
I read several related questions on Stackoverflow, but none seemed to be the same issue or related.
window.onload = function() {
displayField();
};
function displayField() {
jQuery('#groupnumber').change(function() {
var amount5 = jQuery('#groupnumber').val();
if (amount5 > 5) {
alert('Alert message');
}
});
};
//Trigger javascript on leaving field
onblur = "displayField();"
So it "keeps score". If I enter a different value the second time and it is still above 5, I would like the alert box to just show once.
Thanks for any help!