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