所以我有一个表单来提交用户登录数据。但目前数据提交的默认设置是单击按钮。此脚本既可以单击按钮,也可以按Mozilla上的ENTER,但不能在Chrome中按。如何解决我的问题?
JAVASCRIPT:
$(document).ready(function(){
$('#buttonSignIn').click(function(s){
s.preventDefault();
var error = false;
var _wait_ = $(this).attr('data-wait');
var user = $('#user').val();
var pass = $('#password_signin').val();
var waitHtml = $(this).html();
var _wait = '...';
var _waitHtml = waitHtml + _wait;
if( user == '' || user == 0 || trim( user ).length == 0 ) {
var error = true;
$('#user').focus();
}
if( error == false ){
$('#buttonSignIn').attr({'disabled' : 'true'}).html(_waitHtml).css({'opacity':'0.5'});
$.post("asset/ajax/sign_in.php", $("#signin_form").serialize(),function(result){
if( result == 'True' ){
$('#signin_form input, .forgot, #buttonSignIn, #recover_pass_form').remove();
$('#success_signin').fadeIn(500).html(_wait_);
$('#error').fadeOut(500);
$("#signin_form").reset();
$('body,html').animate({
scrollTop: 0
}, 500);
setTimeout(function()
{
window.location.reload();
},500 );
}
else{
$('#error').fadeIn(500);
$('#error').html( result );
$("#signin_form").reset();
$('#buttonSignIn').removeAttr('disabled').html(waitHtml).css({'opacity': 1});
}//<-- ELSE
});//<-- END $POST AJAX
}//<-- END ERROR == FALSE
});//<-- END FUNCTION CLICK
}
<form action="" method="post" name="form" id="signin_form" class="form_login signInForm">
<input type="text" name="user" id="user" placeholder="<?php echo $_SESSION['LANG']['placeholder_email_username']; ?>" title="<?php echo $_SESSION['LANG']['placeholder_email_username']; ?>" />
<input type="password" name="password" id="password_signin" placeholder="<?php echo $_SESSION['LANG']['placeholder_pass']; ?>" title="<?php echo $_SESSION['LANG']['placeholder_pass']; ?>" />
<span id="error"></span>
<span id="success_signin"></span>
<a style="cursor: pointer;" class="recover_pass buttonInside forgot buttonForgot"><?php echo $_SESSION['LANG']['placeholder_forgot_pass']; ?></a>
<button type="submit" id="buttonSignIn" class="button_class" data-wait="<?php echo $_SESSION['LANG']['please_wait']; ?>"><span><?php echo $_SESSION['LANG']['sign_in']; ?></span></button>
<div class="clear"></div>
</form>