Skip to content

xVal Client-side Validation with Dots & Square Brackets

Just so others don’t tear their hair out, it seems the xVal client side validation call Html.ClientSideValidation<TModel> converts (all?) non-A-Z characters to an underscore, I knew dots needed to be replaced for underscore, but it seems square brackets need this as well.

So:

<%= this.TextBox("Supplier.SupplierAddresses[" + Model.CurrentRowIndex + "].Address.Postcode").Value(Model.SupplierAddress.Address.Postcode).Class("postcode").MaxLength(4)%>
<%= Html.ValidationMessage("Supplier.SupplierAddresses[" + Model.CurrentRowIndex + "].Address.Postcode")%>

Needs:

<%= Html.ClientSideValidation<Address>("Supplier_SupplierAddresses_" + Model.CurrentRowIndex + "__Address")%>

To actually work and initialise jQuery client-side validation.

VN:F [1.9.10_1130]
Rating: 4.5/5 (2 votes cast)
VN:F [1.9.10_1130]
Rating: 0 (from 0 votes)
xVal Client-side Validation with Dots & Square Brackets, 4.5 out of 5 based on 2 ratings
Bookmark and Share
kick it on DotNetKicks.com
Shout it

NOW, FOR A WORD FROM OUR SPONSORS

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

My name is Graham O'Neale and I'm a software architect from Gold Coast, Australia. I am an overtime thinker, full time coder and awake part time in the real world. I have a keen interest in software development, particularly in the realm of programming (C#, ASP.NET, ASP.NET MVC, LINQ (2 SQL), Entity Framework, Silverlight, Blend, WCF, WPF) and a keen interest in the cutting edge and innovation. I have a new found love for design patterns, ALT.NET practices and well crafted software architecture. The purpose of this blog is to express any thoughts, findings, tips and gripes along my travels in the wonderful world of coding and technology...