jQuery Validation plugin, IE7 "SCRIPT3: Member not found"
Asked Answered
S

5

15

I have the following:

<html>
    <head>
    </head>
    <body>
        <div>
            <form method="post">
                <div id="questions">    
                    <label for="question-6">Name of Course:</label>
                    <input type="text" name="name_of_course[response]" value="" id="question-6" class="required">
                    <label class="control-label" for="reporting-year">Reporting Year: </label>
                    <select name="reporting_year" id="reporting-year">
                        <option value="-1" selected="selected">Select option...</option>
                        <option value="4">2013-2014</option>
                        <option value="1">2012-2013</option>
                        <option value="2">2011-2012</option>
                        <option value="3">2010-2011</option>
                    </select>
                </div>
                <input type="submit" name="submit" value="Save Entry" class="btn">
            </form>
        </div>
        <script src="//code.jquery.com/jquery.js"></script>
        <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
        <script>
            $(function(){
                jQuery.validator.addMethod("notEqual", function(value, element, param) {
                        return this.optional(element) || value !== param;
                        }, "Please select an option");
                $('form').validate({
                    rules:{
                        'reporting_year': {
                            notEqual: "-1"
                        }
                    }
                });
            });
        </script>
    </body>
</html>

Everyone's favorite browser, IE7 (IE10 w/compatibility really) is reporting the following error in the console:

SCRIPT3: Member not found.

jquery.js, line 2525 character 4

Of course IE8 and above work fine, but my client is using IE7.

Swordsman answered 19/11, 2012 at 21:29 Comment(4)
#7993585Ulrich
@JayBlanchard I saw that one, however even just a regular .validate() function fails. Removing the validate() call stops the error. Reading through the actual plug-in support, there isn't really a good answer. The developer says he "doesn't see the error" and keeps closing bug reports related to it. I was hoping perhaps someone had run across a better way to fix it than that particular post.Swordsman
I am also experiencing the same issue - only in IE7Luzluzader
@Truegilly is that a "real" IE7 or IE8-10 in compatibility mode?Swordsman
C
24

Looks like it's a bug with IE10 in compatibility mode as it is reported to work in IE7. But there are some jquery workarounds posted here: http://bugs.jquery.com/ticket/12577

Crush answered 9/12, 2012 at 0:20 Comment(6)
Thanks for finding that. I guess it is time to get a VM with IE7 on it!Swordsman
you can find licenced / free-ish VMs from microsoft here modern.ie which include IE7 on Vista. Downside is that some of them need to be renewed every 90 days but they are better than stumbling over problems like this without being able to test with a real copy of IE7.Gambetta
www.browserstack.com is useful for testing legacy browser versionsPragmatics
It may or may not be related, but at work, working with IE10 on several computers created from the same image, some colleagues see the "SCRIPT3: Member not found." error while other don't .... The only difference seems to be the fact that a IE10 Security fix has been installed on the machines where no error happens ... The security fix is KB2888505 support.microsoft.com/kb/2888505/en-us ... I hope that helpsBarratry
Some users on the jQuery forum report that the issue does not happen in IE7, but only in IE10 running in IE7 mode.Formant
If you do not need to support IE7, you can instruct the browser to use a newer document mode by using e.g. <meta http-equiv="x-ua-compatible" content="IE=9" >. See also #14383136Formant
F
6

What I found causing the problem is line 35 of jquery.validate.js

this.attr('novalidate', 'novalidate');

Comment out this line and problem is sovled. You could also wrap it with a ( current browser <= ie7) to explictly avoid this line only when ie7 is the broswer.

Update To comment out line only for ie7 you can use the following code:

var ie = (function () {
        var undef,
    v = 3,
    div = document.createElement('div'),
    all = div.getElementsByTagName('i');
        while (
    div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
    all[0]
);
        return v > 4 ? v : undef;
    } ());

and then:

    if (!ie || ie > 7) {
      this.attr('novalidate', 'novalidate');
    }
Fantom answered 11/3, 2013 at 8:16 Comment(0)
S
2

Hello problem from jQuery validation

https://github.com/jzaefferer/jquery-validation/issues/845

Change line 33 of the jquery Validation plugin from:

this.attr( "novalidate", "novalidate" );

to

this.prop( "novalidate", "novalidate" );
Snowbird answered 28/2, 2014 at 5:28 Comment(1)
Woked here too! 3rd party plugin was using .attr(). Thanks!Ozzy
D
1

I was going to add a comment to the answer from Xaris, but wanted to give a little extra info in a full answer. I changed the line in jQuery.validate.js to:

if (!$.browser.msie || $.browser.version > 7) {
    this.attr("novalidate", "novalidate");
}

However, $.browser was removed from jQuery in version 1.9, so I had to add the jQuery Migrate plugin (this is an official jQuery plugin).

If you are using nuget packages in .NET and you use the bundling feature, then keep in mind that you can manually update jQuery.validate.js, but the problem will still exist in jQuery.validate.min.js. I had to delete the minified version so that the bundling wouldn't pick it up in production. It's bad practice to be editing the nuget supplied files as my changes will be overwritten when the package is updated, but this is the best fix for this issue right now.

Dustup answered 24/4, 2013 at 20:45 Comment(1)
jQuery.browser has been replaced with jQuery.support in 1.9 see: api.jquery.com/jQuery.support However jQuery suggests using modernizr.com as the .support api is for internal use only. but i cant see a problem with using it.Simla
D
1

My similar problem

I had the same SCRIPT3: Member not found issue in IE11 due to the defined X-UA-Compatible:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

My solution

In my case, in these days, the application requirements are IE8+.

So, to fix the problem, just remove the meta tag or change it to:

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

Solution to OP's case (or any similar issue)

Depending on the compatibility requirements, it may be used the same solution that I used.

Diep answered 26/11, 2013 at 18:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.