views:

307

answers:

1

I'm using ASP.NET MVC Validation. I want to know in my javascript functions whether the validation has error.

Is there any builtin javascript property integrated with ASP.NET MVC Framework to get this information?

+2  A: 

Built-in ASP.NET MVC validation is server-side only so there is no standard variable like *Page_IsValid* from ASP.NET.

If you want to add client-side validation you could use xVal or jQuery Validation Plugin

Some articles on xVal:

As an option you could validate data on a server and render this JavaScript code in a view:

<script type="text/javascript">
    var Page_IsValid = <%= ViewData.ModelState.IsValid %>;
</script>
Alexander Prokofyev