0
我添加了一個搖動畫動畫類(Css3),當文本框爲空時,但它不能正常工作,因爲asp.net mvc會將用戶重定向到主頁。任何處理這件事的方法。在asp.net中處理jquery函數mvc
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string username, string password)
{
if (ModelState.IsValid)
{
return RedirectToAction("Index", "Product");
}
else
{
return RedirectToAction("Index","Home");
}
}
jQuery函數
$('#loginButton').click(function() {
shaking();
});
function shaking() {
if ($('#username').val() || $('#password').val()) {
}
else {
$('#loginForm').addClass("shake");
setTimeout(function() {
$('#loginForm').removeClass();
}, 2000);
}
};
注意'這裏e'是[jQuery的事件對象(HTTP ://api.jquery.com/category/events/event-object/) – nbrooks 2012-07-14 07:35:39