- <script type="text/javascript" src="Scripts/jquery-1.6.2.js"></script>
- <script type="text/javascript">
- $(function(){
- $("#user_pwd").bind("keydown",function(event){
- if(event.keyCode == 13||e.keyCode ==9)
- {
- //do_login(); js验证表单,最好写ajax校验
- }
- });
- });
- function do_login(){
-
if($.trim($("#user_login_form").find("input[name='username']").val())=="")
{
$.showErr("请输入帐号",function(){
$("#user_login_form").find("input[name='username']").val("");
$("#user_login_form").find("input[name='username']").focus();
});
return false;
}
if($.trim($("#user_login_form").find("input[name='user_pwd']").val())=="")
{
$.showErr("请输入密码",function(){
$("#user_login_form").find("input[name='user_pwd']").val("");
$("#user_login_form").find("input[name='user_pwd']").focus();
});
return false;
} -
var ajaxurl = $("form[name='user_login_form']").attr("action"); //这里完全可以不写action地址,可以指向ajax校验的方法Controller/Action即可
var query = $("form[name='user_login_form']").serialize() ;$.ajax({
url: ajaxurl,
dataType: "json",
data:query,
type: "POST",
success: function(ajaxobj){
},
error:function(ajaxobj)
{
},
}); - }
- </script>