# Can I use autotab function on WIX form

**URL:** <https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422>\
**Category:** Ask the community\
**Tags:** wix-forms, question, code\
**Created:** [December 17, 2020, 6:00am UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422 "2020-12-17T06:00:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![katherines](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@katherines](https://forum.wixstudio.com/u/katherines)\
**Post date:** [December 17, 2020, 6:00am UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422/1 "2020-12-17T06:00:24Z")

</div>

Hi, I’m completely new to Corvid, so I apologize for the possible stupidity of the question in advance.

I have used a WIX form and I need it to autotab between fields once each one reaches maxLength. I tried to use this in the page code:

 ![](https://us1.discourse-cdn.com/wix/original/3X/0/2/02d0266df8ac20394d477124a43ccdcc434270b3.png)

But not working, is there some way of doing this? Would have thought WIX forms would do it automatically once the maxLength has been set, but not sure where to find this setting.

Thanks  
Kathy

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [December 17, 2020, 9:13am UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422/2 "2020-12-17T09:13:30Z")

</div>

Hi there

Please use a custom form, with input fields, and use [**onInput( )**](https://www.wix.com/corvid/reference/$w/textinput/oninput) function to determain whether the input field reached its maximum length, here’s how:

```javascript
// Declare a constant about the input fields and their maximum length:
const inputs = [
    {
        index: 0,
        id: '#name',
        max: 30
    },
    {
        index: 1,
        id: '#serialNumber',
        max: 35
    }
]

inputs.forEach(input => {
    $w(input.id).onInput(() => {
        validateField(input.id);
    })
})

function validateField(id) {
    const inputId = id;
    let index = inputs.map(items => items.id).indexOf(inputId);
    if (index > -1) {
        const inputDetails = inputs[index];
        const input = $w(inputId);
        
        if (input.value.length >= inputDetails.max) {
            if (index + 1 <= inputs.length) {
                const nextId = inputs[index+1].id;
                $w(nextId).focus();
            }
        }
    }
}

```

I took an extra mile to make it compatible with as many fields as you want, you just need to add them in their particular order, set their IDs and their maximum length, and you’re ready to rock.

Hope you find this useful.  
Ahmad

---

<div class="post-metadata">

**Author:** ![katherines](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@katherines](https://forum.wixstudio.com/u/katherines)\
**Post date:** [January 11, 2021, 8:13am UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422/3 "2021-01-11T08:13:40Z")

</div>

Hello Ahmad,

Thank you so much for your help, I’m sorry I couldn’t get it to work. I have made a custom form. If I understand correctly I only need to change the id and max properties to match my form in declaring a constant?

Thanks  
Kathy

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [January 11, 2021, 6:35pm UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422/4 "2021-01-11T18:35:30Z")

</div>

Yes, you only need to change the array with your IDs and the maximum values.  
I had a typo in my code, I’ve updated it, you can use the updated version to see if it fixed your issue.

---

<div class="post-metadata">

**Author:** ![katherines](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@katherines](https://forum.wixstudio.com/u/katherines)\
**Post date:** [January 12, 2021, 3:59am UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422/5 "2021-01-12T03:59:47Z")

</div>

@ahmadnasriya It worked! Thank you sooooo much!!

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [January 12, 2021, 5:40am UTC](https://forum.wixstudio.com/t/can-i-use-autotab-function-on-wix-form/9422/6 "2021-01-12T05:40:35Z")

</div>

@katherines Glad that it worked 😊 You’re welcome.  
Feel free to tag me whenever you want.
