使用jquery登录后的警报消息 [英] Alert message after log in using jquery

查看:66
本文介绍了使用jquery登录后的警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用户登录时有一个登录页面我必须显示成功登录。我正在使用MVC和jquery但我的警报消息在验证之前弹出。我想在用户名和密码更新后显示消息。



I am having a login page when user log in i have to show Successful login.I am using MVC and jquery but my alert message was popping up before validation.I want to show the message after the username and pwd are validated.

<script>

    $('#btsubmit').click(function () {

       
        alert("Logged in");
    });
</script>





< input type =submitid =btsubmitvalue =登录/>





<input type="submit" id="btsubmit" value="Log in" />

[ValidateAntiForgeryToken]
       public ActionResult Login(LoginModel model, string returnUrl)
       {
           if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
           {

               return RedirectToLocal(returnUrl);
           }

           // If we got this far, something failed, redisplay form
           ModelState.AddModelError("", "The user name or password provided is incorrect.");
           return View(model);
       }

推荐答案

' < span class =code-string>#btsubmit')。click( function (){


alert( 登录);
});
< / script>
('#btsubmit').click(function () { alert("Logged in"); }); </script>





< input type =submitid =btsubmitvalue =登录/>





<input type="submit" id="btsubmit" value="Log in" />

[ValidateAntiForgeryToken]
       public ActionResult Login(LoginModel model, string returnUrl)
       {
           if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
           {

               return RedirectToLocal(returnUrl);
           }

           // If we got this far, something failed, redisplay form
           ModelState.AddModelError("", "The user name or password provided is incorrect.");
           return View(model);
       }


你可以在这里找到答案:



http://stackoverflow.com/questions/7553575/how-to- display-message-box-using-mvc3-controller [ ^ ]



http://stackoverflow.com/questions/23591266/display-popup-confirmation-message-with-mvc-c-sharp-after -postback [ ^ ]



http://stackoverflow.com/questions/8965018/dynamically-creating-bootstrap-css-alert-messages [ ^ ]
You can find your answer here:

http://stackoverflow.com/questions/7553575/how-to-display-message-box-using-mvc3-controller[^]

http://stackoverflow.com/questions/23591266/display-popup-confirmation-message-with-mvc-c-sharp-after-postback[^]

http://stackoverflow.com/questions/8965018/dynamically-creating-bootstrap-css-alert-messages[^]


这篇关于使用jquery登录后的警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆