I have a login form in PHP which works on ajax, it works very well when i click on the login button, but not on pressing the enter key.
I did a lot of research on it and tried all the solutions posted on this site regarding the same and tried out all the solutions, but nothing is working for me.
My HTML is wrapped in a div id ="mini-login"
<div class="content-login">
<h4>Email Address:</h4>
<input type="text" name="email" value="" />
<h4>Password:</h4>
<input type="password" name="password" value="" id="pasword"/>
<br />
<a href="<?php echo $forgotten; ?>"><?php echo $text_forgotten; ?></a><br />
<br />
<input type="button" value="<?php echo $button_login; ?>" id="button-login-mini" class="button" />
And my script-
$('#button-login-mini').live('click', function() {
$.ajax({
url: 'index.php?route=module/login/validate',
type: 'post',
data: $('#mini-login .content-login :input'),
dataType: 'json',
beforeSend: function() {
$('#button-login-mini').attr('disabled', true);
$('#button-login-mini').after('<span class="wait">Please wait</span>');
},
complete: function() {
$('#button-login-mini').attr('disabled', false);
$('.wait').remove();
},
success: function(json) {
$('.warning, .error').remove();
if (json['redirect']) {
$('#mini-login .content-login').fadeOut('slow');
location = json['redirect'];
} else if (json['error']) {
$('#mini-login .content-login').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '</div>');
$('.warning').fadeIn('slow');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
So the above is working very well, but i tried to call it on enter key using- keyup, keydown, keypress and checking the keyCode==13, but it did not work, tried using forms as well, now going nuts over this!!! what am i doing wrong?? and how to make it work??
Note: The login page is not an entire document, it slides down on clicking login link on home page.
This is how the login page is called-
$(document).ready(function() {
$('#mini-login > .heading-login a').live('click', function() {
$('#mini-login').addClass('active');
$('#mini-login').load('index.php?route=module/login #mini-login > *');
$('#mini-login').live('mouseleave', function() {
$(this).removeClass('active');
});
});
});