Abdul Waheed Abdul Waheed - 1 month ago 7
Ajax Question

How can i allow enter button to submit form

Hi i am trying to send form using enter button usually by default when i click enter the form will submit but in this oage i am unablr to proceed to form submit when i press enter button.

i can submit the form only by using mouse click on "login" i am sending with ajax

enter image description here

hi this my llogin form:

<form class="form-horizontal" id="loginForm" >
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Email" name="login_email" id="login_email">
</div>
<div class="form-group has-feedback">
<input type="password" class=" form-control" placeholder="Password" name="login_password" id="login_password">
</div>
<div class="text-center form-group">
<input type="button" name="login_button" id="login_button" class="btn btn-default btn-block btn-primary" value="LOG IN">
</div>
<p class="small">
<h6 class="text-center"><a href="forgot-password.php">
Forgotten account Password?</a></h6>
<div class="processloader_login"></div>
</p>
<div class="form-group">
<a href="signup.php " class="btn btn-block btn-success">CREATE AN ACCOUNT</a>
</div>
</form>

Answer

you don't have a submit button try a keypress event & the submit() function

$('body').keypress(function(e){
if (e.keyCode == 13)
{
    $('#loginForm').submit();
}
});

or change

<input type="button" to a type submit