Guest User

Untitled

a guest
Feb 8th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <form id ="FormLogin">
  2. @Html.AntiForgeryToken()
  3. <input class="login" id="username" type="text" placeholder="username">
  4. <input class="password" id="password" type="password" placeholder="password">
  5. <button id="buttonFormLogin"><img src="~/Content/img/enter.png" alt="enter">Log in</button>
  6. <a class="forgot" href="@Url.Action("Check1", "Home")">Forgot Password</a>
  7. </form>
  8.  
  9. [RequireHttps]
  10. [RoutePrefix("Home")]
  11. public class HomeController : Controller
  12. {
  13. [HttpPost]
  14. [ValidateAntiForgeryToken]
  15. [Route("Check")]
  16. public ActionResult CheckLogin(LoginAccount i_User)
  17. {
  18. if (ModelState.IsValid)
  19. {
  20.  
  21. }
  22.  
  23. return RedirectToAction("Login");
  24. }
  25. }
  26.  
  27. public class LoginAccount
  28. {
  29. [StringLength(15)]
  30. [RegularExpression("(^[0-9a-zA-Z]{1,15}$)")]
  31. [Required(ErrorMessage = "Username is required")]
  32. [DataType(DataType.Text)]
  33. public string Username { get; set; }
  34.  
  35. [StringLength(15)]
  36. [RegularExpression("(^[0-9a-zA-Z@!%]{1,15}$)")]
  37. [DataType(DataType.Password)]
  38. public string Password { get; set; }
  39. }
  40.  
  41. $('#buttonFormLogin').click(function () {
  42. $('form#FormLogin').submit();
  43. });
  44.  
  45. $("#FormLogin").on('submit', function (e) {
  46. e.preventDefault();
  47. var data = {
  48. Username: $('#username').val(),
  49. Password: $('#password').val()
  50. };
  51.  
  52. $.post('@Url.Action("Check", "Home")', { i_User: data },
  53. function () { alert('Successfully posted to server'); });
  54. });
Add Comment
Please, Sign In to add comment