Hello,
I’m trying to use onblur to validate a textfield. I want to use on blur because there is the possibility that the user will use either a mouse or the tab button to navigate the form.
The code I did was something like:
function checkNull(formField){
var value = formField.value;
if(value==null || value==””){
alert(“This is a mandatory field. Please enter something”);
formField.focus();
}
}
I’ve read that when an alert (window.alert() dialog box) is displayed, the textfield loses focus and then regains focus after the alert is closed. This can cause a loop to form. In my case if I leave out the formField.focus() line, the cursor returns to whatever other textfield you had tabbed onto. But if put in the formField.focus() line the code seems to go into a loop. Every time you click on the OK button in the alert box another alert box pops up.
Is there any way to prevent this loop from happening ?
Thanks in adavance,
Trish.