Skip to content

Object doesn't support property or method 'hasAttribute' error appears on old IE browsers #2141

Closed
@lopezcjf

Description

@lopezcjf

I'm experiencing some issues with users that are working with old versions of IE (version 10 and below or 11 with enabled compatibility mode)
I have a really basic login page and using version 1.17.0 but this was happening also on previous versions.

The error appears when focusing out from a required field. The following error is displayed on the console:

Object doesn't support property or method 'hasAttribute'

The error is thrown on line 705

if ( element.hasAttribute( "contenteditable" ) ) {
	val = $element.text();
} else {
	val = $element.val();
}

Somehow on old versios of IE the element object doesn't contain that method.
I was able to fix this by changing that line to the jquery function hasOwnProperty instead.

$element.hasOwnProperty( "contenteditable" )

The same can be found on line 152 and the same error should appear there.

This is my validation setup:

$('.login-form').validate({
    errorElement: 'span', 
    errorClass: 'help-block', 
    focusInvalid: false, 
    rules: {
        UserName: {
            required: true
        },
        Password: {
            required: true
        }
    },
    messages: {
        UserName: {
            required: resources.IngresarUsuario
        },
        Password: {
            required: resources.IngresarPWD
        }
    },
    invalidHandler: function (event, validator) {
        $('.alert-danger', $('.login-form')).show();
    },
    highlight: function(element) { 
        $(element).closest('.form-group').addClass('has-error');
    },
    success: function (label) {
        $(label).closest('.form-group').removeClass('has-error');
        $(label).remove();
    },
    errorPlacement: function (error, element) {
        $(error).insertAfter($(element).closest('.input-icon'));
    },
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions