On enter scroll down to next input field and select it ready to write somthing.
I'm hoping this makes sense, but I am building a form and have got a script that so far has disabled submission on enter and scrolls down to the next input field.
However I want that next input field to have the cursor selected and to be ready to start typing.
This is what I have so far;
- jQuery('form input').keydown(function (e) {
- if (e.keyCode == 13) {
- var nextQuestion = jQuery(this).closest('.form--wrapper').next();
- if (nextQuestion.length !== 0) {
- jQuery('html, body').animate({
- scrollTop: nextQuestion.offset().top
- }, 1000);
- jQuery(this).next(':input').select();
- }
- e.preventDefault();
- return false;
- }
- });
I tried
jQuery(this).next(':input').select(); but that didn't work and anything else i've tried has made the submission button active again....