0

I am working on a form and in that form button is disabled by starting and after filling the form button will get able to submit it. Now, I want that after filling the form the user should be able to submit the form by clicking enter button as well and it should validate if the all the fields are filled or not as well. I want this functionality with Jquery only.

Thanks in advance.

Here is the code on which I want this to be:-

<html>
    <head>
        <title></title>
    </head>
    <body>

    <div class="form-group"> 
    <label for="URL">Website - (Optional Field)</label> 
    <input class="form-control" id="URL" placeholder="www.example.com" type="url"> 
    </div> 
    <div class="form-group"> 
    <label for="Legal_Name">Name</label> 
    <input class="form-control" id="Legal_Name" placeholder="Enter Your Legal Name" type="text"> 
    </div> 
    <div class="form-group"> <label for="Doing_Business">Doing As - (Common Name) </label> 
    <input class="form-control" id="Doing" type="email"> 
    </div> 
    <button type="submit" class="btn btn-default section_btn section-5-next hover_ease btn_disable">Next</button>

    </body>
    </html>
<script>$('.section-5-next').click(function(){
    $('.section-5').hide();
        $('.section-6').fadeIn();
        $('.Progress_Status').html('35%').css({'width':'35%'});
    });
</script>

2 Answers2

0

You can do like this using jquery:

<script>
$(document).ready(function(){
    $('.section-5-next').click(function(){
        $('.section-5').hide();
        $('.section-6').fadeIn();
        $('.Progress_Status').html('35%').css({'width':'35%'});
    });
    $('.form-control').keypress(function (e) {
        if (e.which == 13) {
          $('form').submit();
        }
    });
});
</script>
Himanshu Upadhyay
  • 6,220
  • 1
  • 13
  • 32
0

Check this Submit form with Enter key without submit button?

$("input").keypress(function(e) {
    if (e.which == 13) {
        event.preventDefault();
        $("#formtosubmit").submit();
    }
});
Samuel James
  • 1,350
  • 12
  • 15