ASP.NET MVC Validation: result of using javascript property?

I am using ASP.NET MVC validation. I want to know in my javascript functions whether validation has an error.

Is there a built-in javascript property integrated with the ASP.NET MVC Framework to get this information?

+3
source share
1 answer

ASP.NET MVC built-in validation is server-only, so ASP.NET does not have a standard variable such as Page_IsValid.

If you want to add client-side validation, you can use xVal or the jQuery validation plugin

Some articles about xVal:

JavaScript :

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

Source: https://habr.com/ru/post/1711724/


All Articles