Home Dashboard Directory Help
Search

Please support jQuery v1.9.0 properly in jquery.validate.unobtrusive by MagnusJay


Status: 

Active


55
0
Sign in
to vote
Type: Bug
ID: 776965
Opened: 1/19/2013 4:36:41 AM
Access Restriction: Public
3
Workaround(s)
view
17
User(s) can reproduce this bug

Description

Hi,

since upgrading to jQuery v1.9, and using the latest jquery.validate.unobtrusive (Microsoft.jQuery.Unobtrusive.Validation" version="2.0.20710.0")

my code crashes with
Line: 524
Error: Invalid character
in jQuery.

The reason seems to be that jquery.validate.unobtrusive is calling jQuerys parseJSON with an undefined value. This was accepted in earlier version of jQuery, but v1.9+ does correctly now throw an error.

Also see:
https://forum.jquery.com/topic/parsejson-in-1-9-0-is-different-from-earlier-versions
Details
Sign in to post a comment.
Posted by Rob_ICS on 5/7/2013 at 4:33 AM
This is not fixed in the latest version.
Posted by marianotigre on 5/3/2013 at 7:42 AM
Is this bug fixed?
Posted by Andreas Larsen on 3/29/2013 at 12:42 PM
To be clear, before clearing the browser cache I also ran a Build Clean, and in my best superstition also deleted all bin and obj folders before rebuilding in the hopes to delete any server side caching of the javascript bundling.
It did not have any effect on its own, so I then force refreshed the browser, and that's when it fixed the problem for me.
It is possible that a combination of cleaning both server side and client side cache was necessary. I'm not sure.

There is a SO post here: http://stackoverflow.com/questions/14822540/syntax-error-with-parsejson-during-unobtrusive-validation
Posted by Andreas Larsen on 3/29/2013 at 12:24 PM
After digging some more, it seemed it was the cache of my browser that did not pick up the changes. I force refreshed the page and the validation errors no longer occur.
Posted by Andreas Larsen on 3/29/2013 at 12:11 PM
Same here. The error still applies to 2.0.30116.0.
Posted by Jorin Slaybaugh on 3/25/2013 at 9:40 AM
I'm with @chuck02323. I've just installed 2.0.30116.0 via nuget and am still getting "Uncaught type error: unexpected token: u". When I add in jQuery.Migrate 1.1.1 it works, but lets me know that "jQuery.parseJSON requires a valid JSON string" so it is clearly still choking on undefined.

Also, might I suggest that in the comment header at the top of jquery.validate.unobtrusive.js (or any other plugin for that matter) you guys put the version number so we can be sure what version is actually there?? As it is now, the only way we have any idea of the version number is from nuget, so if the package is busted somehow and adding in old files, there's no way to know for sure.
Posted by stmarti1 on 3/18/2013 at 6:56 AM
The range validator is completely broken. Please fix it.
Posted by StijnHerreman on 3/15/2013 at 3:48 AM
chuck02323, are you talking about the undefined JSON issue, or a different issue?
We've verified that with 2.0.30116.0 the issue no longer occurs, normal and minified libraries. Switching back to the previous version immediately reintroduces the issue, so I think it's safe to say that at least something was fixed.
Posted by chuck02323 on 3/7/2013 at 6:29 AM
Not fixed as of 3/4/13 or at least it's not fixed in 2.0.30116.0 published 2/18/13
Posted by Microsoft on 2/27/2013 at 2:02 PM
Thank you for reporting this issue. The issue has been fixed in our latest release. Please do keep the feedback flowing.

Regards,
ASP .Net Team
Posted by Lajos Marton on 2/9/2013 at 2:42 PM
There is another bug in the unobtrusive js.
For example ASP.NET MVC Range validation doesn't work anymore.
adapters.AddMinMax should be like this:
var min = Number(options.params.min),
     max = Number(options.params.max);

I think there will be more errors, if somebody would check all of adapters. Please fix unobtrusive.js ASAP.
Posted by Code Chief on 1/30/2013 at 7:59 AM
Also the "cancel" class is broken, added a workaround for that I found from somebody else.

Please raise the priority of this issue so it will be fixed soon!!!
Posted by Code Chief on 1/30/2013 at 3:52 AM
Please include the update of jquery.unobtrusive-ajax.js when you add support for jQuery 1.9. I am not getting post backs in the right place, it is replacing the whole page not the target ID which worked before.

Because people are using NuGet Package Manager more with Visual Studio 2012 I'd say this is a pretty critical issue (we are prompted to update when we start VS 2012). If you can produce a hotfix soon rather than a long rewrite please do that ASAP!
Posted by Microsoft on 1/20/2013 at 10:01 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 1/19/2013 at 4:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Code Chief on 1/30/2013 at 8:02 AM
You should also install the "jQuery Migrate" NuGet package to fix the use of the depreciated ".live()" method calls. But that is just a workaround, as soon as MS fix this you should remove the migrate package to ensure all your scripts are compliant with current standards.
Posted by Code Chief on 1/30/2013 at 8:00 AM
To workaround the "cancel" class being ignore (not causing validation to be skipped as it should) see here:

http://jimmylarkin.net/post/2012/05/16/Broken-Validation-on-Cancel-Buttons-With-Unobtrusive-Validation-Ajax.aspx

Logged as an issue here....

http://aspnet.codeplex.com/workitem/7964
Posted by Code Chief on 1/30/2013 at 3:49 AM
To fix the "invalid character" issue, edit jquery.validate.unobtrusive.js and make these changes:

Line 43: replace = container.attr("data-valmsg-replace") && $.parseJSON(container.attr("data-valmsg-replace")) !== false;

Line 73: replace = container.attr("data-valmsg-replace") && $.parseJSON(container.attr("data-valmsg-replace"));