1
問候,一些驗證的一個問題有點...MVC文本框驗證
型號:
public class Class1
{
[Required(AllowEmptyStrings = false, ErrorMessage="Error")]
public String test { get; set; }
}
控制器:
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public ActionResult TestClick()
{
return View();
}
}
查看:
<script type="text/javascript">
function TestClick() {
$.post("/Home/TestClick");
}
</script>
<h2>Index</h2>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true);
@Html.EditorFor(mod => mod.test)
@Html.ValidationMessageFor(mod => mod.test);
<a href="#" onclick="TestClick()">Test</a>
}
TestClick()在第一個Loa上觸發並執行該帖子D沒有被驗證...如果文本被改變驗證阻止帖子...如何驗證之前的jQuery文章?
使用{}標籤來轉義您的代碼。我們無法看到您的視圖標記。 – Vadim 2011-01-27 21:33:52