3

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?

1 Answer 1

2

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> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.