max length input redirect to another link

when a 6 max length is enter in the input, I want it to automatically post and redirect to another link. so I don’t want it to work with the button. thank you for your help.

 <form novalidate="novalidate" class="v-form mt-8" action="" method="post" id="user">

<input maxlength="6" id="user" placeholder="******" type="text" autofocus="autofocus" value="" name="code" style="color:black!important;">
    <script>
        var user = document.getElementById('user');
        
        function checkLength(){
          if(user.value.length === 6){
            window.location.assign('http://stackoverflow.com')
          }
        }
        </script>

actually, this script works, but I need to delete the post code. then its not post.