-3

I have a little form with three checkbox and one of them is attached to an 'input number' and if the checkbox is checked is takes the number and calls a function.

The problem is that if I enter the number and press the ENTER key the page reloads. I suppose that its because I'm submitting the form to nowhere.

How can I change that to on enter not send the form but call the function again?

Thanks.

<div class="input-group">
    <span class="input-group-addon">
        <input type="checkbox" id="filterLenght" value="lenght" onClick="redraw()">
        MinLenght
        <br>
    </span>
    <input type="number" class="form-control" id="filterLenghtNumber" value="200">
</div>
CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176
Sergiodiaz53
  • 1,268
  • 2
  • 14
  • 23

1 Answers1

1

The way to deactivate the 'enter -> submit':

        $("#formID").submit(function() {
            return false;
        });

The way to call a function when press key ENTER in a input type:

        $("#InputID").keyup(function (e) {
            if (e.keyCode == 13) {
                redraw();
            }
        });
Sergiodiaz53
  • 1,268
  • 2
  • 14
  • 23