I have been assigned the task of forcing a linear progression through a form using JavaScript. I am trying to use jQuery to do this. My example here is supposed to validate a field on blur, and if it is not valid then display the error message and return focus to the field.
This code does precisely what I want it to:
However, it only performs correctly in Chrome. In Firefox and Internet Explorer, it does not force focus back on the field correctly.
How can I write this to evoke the correct response to invalid data in all three browsers (Chrome, Firefox, and Internet Explorer)? I began using jQuery with the understanding that the code should work the same anywhere.
This code does precisely what I want it to:
Code:
// Validate fields on page blur, even directly following page load.
$("input").blur(function() {
var validdd = $(this).valid();
if (validdd != 1) {
$(this).focus();
}
});
However, it only performs correctly in Chrome. In Firefox and Internet Explorer, it does not force focus back on the field correctly.
How can I write this to evoke the correct response to invalid data in all three browsers (Chrome, Firefox, and Internet Explorer)? I began using jQuery with the understanding that the code should work the same anywhere.