回車鍵不起作用。填寫表格後不起作用。我不想使用表格標籤。回車鍵不起作用
<div>
<label style="color:white;"> Name:</label>
<input type="text" class="span2" name="loginname" id="loginname" />
<label style="color:white;"> password</label>
<input type="password" class="span2" name="loginpass" id="loginpass" />
<button type="submit" class="btn btn-success" autofocus onclick="login()">enter</button>
</div>
因爲我用了codeginiter的ajax。
function login(){
var usr = $('#loginname').val();
var pass= $('#loginpass').val();
$.ajax({
type: "POST",
url: "http://localhost/ci/index.php/user/register",
data: { "isim": usr,
'pass' : sifre,
},
success: function(msg){
if (msg=="ok") {
window.location = "http://localhost/ci/index.php/user/main";
}else{
new Messi(msg, {title: 'ERROR', modal: true});
}
}
});
}
}
}
添加你的js函數login()。 –
嘗試'onsubmit'而不是'onclick' – krishna
爲什麼不使用專門爲您設計的標籤? – berentrom