ASP.Net MVC Unobtrusive Validation Bug

If you use the ASP.Net MVC 3 [Compare] validation attribute on a model property, then include that model as a property in a parent model (so that the field name becomes Parent.ChildProperty), the built-in unobtrusive client validation will choke, and will always report the field as having an error.

This is due to a bug on line 288 of jquery.validate.unobtrusive.js:

adapters.add("equalto", ["other"], function (options) {
    var prefix = getModelPrefix(options.element.name),
        other = options.params.other,
        fullOtherName = appendModelPrefix(other, prefix),
        element = $(options.form).find(":input[name=" + fullOtherName + "]")[0];

    setValidationValues(options, "equalTo", element);
});

Because the value of the name attribute selector is not quoted, this fails if the name contains a ..

The simplest fix is to add quotes around the concatenated value.  However, the jQuery selector there is overkill.  HTML form elements have properties for each named input, so you can do this instead:

adapters.add("equalto", ["other"], function (options) {
    var prefix = getModelPrefix(options.element.name),
        other = options.params.other,
        fullOtherName = appendModelPrefix(other, prefix),
        element = options.form[fullOtherName];
    if (!element)
        throw new Error(fullOtherName + " not found");
    //If there are multiple inputs with that name, get the first one
    if (element.length && element[0])        
        element = element[0];
    setValidationValues(options, "equalTo", element);
});

417 comments:

«Oldest   ‹Older   401 – 417 of 417   Newer›   Newest»

Have you ever tasted the Jackfruit Chips from Nagercoil?.. Sweetkadai.com delivers the Best Jackfruit Chips at your doorstep.. Order now!!

Sparkling chess academy is run by international rated players. We have a long journey of success because of our commitments, dedication and love for the game of chess. We believe in “practice makes men perfect” that’s why we are running our chess academy all seven days. Our main objectives are to bring out our student’s full potential and his/her all round development. We have chess academy in Delhi, Noida & Faridabad.

//old-blog.slaks.net/2012/02/aspnet-mvc-unobtrusive-validation-bug.html

http://tech.agora.org/2015/06/google-apps-for-education-is-live.html?sc=1659963368088#c8502427072550134193

People going in the FinTech era must know What Bank Is Cash App On Plaid. It is a kind of certain technique the bank use to integrate with the plaid for making the customer's experience better. But sometimes, you might not realize the tactics and may fall into trouble. This is why choosing the working tactics can help you get to the information at once. A cash app is a system that allows the transactional aspect through secure methods. Most often the lack the complete information leads to troublesome kind of factors and finally cash app users could not deal with it. This is why; they may select to take the help of the support team.

If you are one of those users who are looking forward to knowing the usages of Cash App Fee Calculator, you have to make use of expert’s backing and supervision so that you can leverage the benefits of Cash App at its best. However, if you are having any kind of hassle regarding the same, you have to contact the Cash App support engineers who will help you to use the Cash App calculator at its best.

Of course, there is an eligibility criterion that you have to match if you would like to use Cash App Borrow feature to borrow money directly from Cash App. However, if you meet the criteria and are ready to take a loan, you should make sure that you can take money from $20 to $200 without any kind of problems. Apart from that, you should have a word with the Cash App geeks who will let you know all about the same.

This very informative and interesting blog.
sell my house fast ontario

Thank you for your valuable information. This article is very useful.
Traffic Lawyer Fauquier VA
Abogado Tráfico Botetourt VA

I just want to say that your article is very useful to us. I saw its different posts and article on this site.
DUI Lawyer Washington County VA
Washington County DUI VA

Nice Post
Are you struggling with your assignments and need help? My Assignment Help Singapore is here to provide you with the best assignment help in Singapore! Our team of assignment helpers in Singapore has the knowledge and expertise to deliver high-quality, custom assignments that meet your specific needs. We are committed to helping you achieve academic success and are always ready to assist you with your assignments. So why wait? Contact us today for help with assignment!

Great post
When it comes to ensuring your academic success, having access to the best college assignment help in Greece is crucial. At Greeceassignmenthelp.com, we have a team of talented writers who specialize in a wide range of academic fields and can provide you with the top-notch writing support you need to excel.

quiebras de abogadosThanks for your information.Very useful.

This comment has been removed by the author.

Great Blog!! Lovely process and excellent procedure...

Abogado de Lesiones Personales Virginia Beach

«Oldest ‹Older   401 – 417 of 417   Newer› Newest»

Post a Comment