0
嗨,我是新來的php,我有一個如下所示的php表單,它在我應用bootstrap之前工作。將PHP表單按鈕綁定到javascript方法
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Login Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" href="css/login.css" rel="stylesheet" />
<link type="text/css" href="css/bootstrap/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<!-- Main Container -->
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title">Sign in to HRMS</h1>
<div class="account-wall">
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120"
alt="">
<form class="form-signin" method="post" action="">
<input type="text" id="txtEmpID" class="form-control" placeholder="Employee ID" required autofocus>
<input type="password" id="txtEmpPass" class="form-control" placeholder="Password" required>
<button id="btnLogin" class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var login_url = "<?php echo Util::convertLink("Login") ; ?>" ;
<?php include (PATH_CODE . "js/general/login.min.js") ; ?>
</script>
</body>
</html>
與按鈕登錄綁定到login.js
$(document).ready(function()
{
$('#btnLogin').button().bind('click',this,onLogin) ;
}) ;
function onLogin(obj) {
alert($('#txtEmpID').val());
}
它有我丟失的東西的方法?
首先,VAR LOGIN_URL = 「」;嘗試使用$('#btnLogin')。click(function(){alert($('#txtEmpID')。val()); return false;}); –
看起來你的表單沒有動作=「」 - >所以當你提交時,它什麼都不做。將它指向您的登錄腳本以解析formdata中的信息。 –
它有什麼作用?它警覺嗎?你有沒有包含jQuery? – putvande