$(document).ready(function(){
//$('#loginButton').focus();
$('#password').bind('keyup', function(event){
if (event.keyCode=="13"){
subLogin();
}
});
$("#loginButton").click(function(){
subLogin();
});
});
function subLogin(){
if(usernameLogin()){
$.ajax({
type:"POST",
url:"http://localhost:8080"+basePath + "/composite/login1.action?caccountName="+$('#username').val()+"&password="+$('#password').val(),
dataType:'json',
success:function(data){
if(data.success == "true"){
alert(data.msg);
$('#username').val("");
$("#password").val("");
}else{
location.href ="http://localhost:8080/misps/portal/index.jsp";
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
};
}
function usernameLogin(){
var t_name = $.trim($('#username').val());
$('#username').val(t_name);
var t_pass = $.trim($("#password").val());
$("#password").val(t_pass);
if (t_name == '' || t_pass == '') {
alert("用户名或密码不能为空");
return false;
}else{
return true;
}
}