onblur infinite alert issue fix

Issue: Infinte alert pop up when you use onblur event. This issue have been monitored in Safari, IE.
Root Cause: Each time clicking on 'Ok' button of the alert, onblur happens and we are trapped in an infinite loop.

Fix:

You can refocus the control to different element in the form to get rid off an infinite alert pop up due to onblur  event usage in your application

Sample code given below

<script type="text/javascript">
function validate()
{
if(document.getElementById('txtval').value != " ")
{
alert("not valid value");
document.getElementById('txtint').focus();
}
}
</script>
<form>
<input type="text" id="txtval"  name="txtval" onblur="validate();">
<input type="text" name="txtint" id="txtint" >
</form>
Note:I faced this issue in Safari browser here, but i remember same issue i have been faced in IE as well.

Comments

Popular posts from this blog

how to add new line in google form questions | Fix for next line issue in google form questions

How to add new line in dropdown type question in google forms