Client-side validation not getting rules from JsonFormatter

Apr 29, 2009 at 3:47 AM

Hi,
I'm having some trouble getting the client-side validation to work in xVal. The documentation I'm looking at is from 0.5, but I couldn't find anything more recent. I have the following DTO and view. Server-side validation is working just fine, but the client side validation is not cooperating. Am I missing something completely obvious?

The output of the helper method is: <script type="text/javascript">xVal.AttachValidator(null, {"Fields":[]})</script>  (It doesn't seem the Json Formatter is doing its thing.)

Thanks,
Zach

public
class LoginDetailsSubmitted{
[
ValidateNonEmpty][ValidateEmail]public string EmailAddress { get; set; }
[
ValidateNonEmpty]public string Password { get; set; }}

<% Html.BeginForm(

"Login", "Registration"); %><div>
<label>Email Address</label>
<%= Html.TextBox("EmailAddress") %>
<%
= Html.ValidationMessage("EmailAddress")%>
</div>
<div>
<label>Password</label>
<%= Html.Password("Password")%>
<%
= Html.ValidationMessage("Password")%>
</div>
<input type="submit" />
<% Html.EndForm(); %>
<%
= Html.ClientSideValidation<LoginDetailsSubmitted>()%>

 

Apr 29, 2009 at 3:57 AM
I just found the notes on 0.8 and saw the bit about adding an ActiveRuleProvider. That fixed everything.

Thanks for the work on the xVal. Validation is my least favorite part of development and I'm glad for anything that makes it easier.

xVal.

ActiveRuleProviders.Providers.Add(new CastleValidatorRulesProvider());

 

Coordinator
Apr 29, 2009 at 10:37 AM
Glad you figured that bit out. I'm aware of a pressing need to improve the documentation to make this point clearer.
Sep 18, 2009 at 3:21 PM

I ran into this problem today!

I was using the dll's from the model binder found here: http://www.asp.net/learn/mvc/tutorial-39-cs.aspx

They don't play nice with xVal.  I swapped it out for the regular dll  and now it works great.

I figured I'd post this incase anyone else ran into the problem.