Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form id ="FormLogin">
- @Html.AntiForgeryToken()
- <input class="login" id="username" type="text" placeholder="username">
- <input class="password" id="password" type="password" placeholder="password">
- <button id="buttonFormLogin"><img src="~/Content/img/enter.png" alt="enter">Log in</button>
- <a class="forgot" href="@Url.Action("Check1", "Home")">Forgot Password</a>
- </form>
- [RequireHttps]
- [RoutePrefix("Home")]
- public class HomeController : Controller
- {
- [HttpPost]
- [ValidateAntiForgeryToken]
- [Route("Check")]
- public ActionResult CheckLogin(LoginAccount i_User)
- {
- if (ModelState.IsValid)
- {
- }
- return RedirectToAction("Login");
- }
- }
- public class LoginAccount
- {
- [StringLength(15)]
- [RegularExpression("(^[0-9a-zA-Z]{1,15}$)")]
- [Required(ErrorMessage = "Username is required")]
- [DataType(DataType.Text)]
- public string Username { get; set; }
- [StringLength(15)]
- [RegularExpression("(^[0-9a-zA-Z@!%]{1,15}$)")]
- [DataType(DataType.Password)]
- public string Password { get; set; }
- }
- $('#buttonFormLogin').click(function () {
- $('form#FormLogin').submit();
- });
- $("#FormLogin").on('submit', function (e) {
- e.preventDefault();
- var data = {
- Username: $('#username').val(),
- Password: $('#password').val()
- };
- $.post('@Url.Action("Check", "Home")', { i_User: data },
- function () { alert('Successfully posted to server'); });
- });
Add Comment
Please, Sign In to add comment