Setting focus back to the current field on field change
I am trying to set focus back to the field that I am currently changing when click tab and the field fails validation.
When the form loads I set focus to $('.ScanBarcode-field').focus(); which works. When the user enters a value and hits "tab"
fd.field('ScanBarcode').change(function(){
//Validation rules fail
$('.ScanBarcode-field input').focus();
});
I am expecting the focus to return to the field that just changed. What am I missing?
Thanks
When the form loads I set focus to $('.ScanBarcode-field').focus(); which works. When the user enters a value and hits "tab"
fd.field('ScanBarcode').change(function(){
//Validation rules fail
$('.ScanBarcode-field input').focus();
});
I am expecting the focus to return to the field that just changed. What am I missing?
Thanks
It could be a number of reasons, but my initial question is why are you doing
when
is as you say what works?
Code: Select all
$('.ScanBarcode-field input').focus();
Code: Select all
$('.ScanBarcode-field').focus();
I assume ScanBarcode is a text field. Try this:
Code: Select all
fd.field('ScanBarcode').change(function(){
setTimeout(function(){
$('.ScanBarcode-field input').focus();
},0);
});
-
- Information
-
Who is online
Users browsing this forum: No registered users and 19 guests