This is a migrated thread and some comments may be shown as answers.

Test for duplicates is not working in MS IE 11, works fine Firefox

1 Answer 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Veteran
Andrey asked on 09 Nov 2018, 06:01 PM

Hello,

I have a function to check for duplicates when an email inserted. It worked fine in Firefox and Google Chrome - no error, no warning. In IE it reports error:

"0x800a138f - JavaScript runtime error: Unable to get property 'Email' of undefined or null reference" in line : "if (cnt > 1 && $.trim(data[item].Email).toLowerCase() == currentEmail) {"

Did I miss some javascript settings for IE?

Thanks!

 

                                        (function ($, kendo) {
                                            $.extend(true, kendo.ui.validator, {
                                                rules: {
                                                    dupemailvalidation: function (input, params) {
                                                        if (input.is("[name='Email']") && input.val() != "") {
                                                            input.attr("data-dupemailvalidation-msg", "Duplicated email address");
                                                            var currentEmail = $.trim(input.val()).toLowerCase();
                                                            var cnt = 0;
                                                            var data = $('\#GridEmails').data('kendoGrid').dataSource.data();
                                                            for (item in data) {
                                                                cnt++;
                                                                if (cnt > 1 && $.trim(data[item].Email).toLowerCase() == currentEmail) {
                                                                    return false;
                                                                }
                                                            }
                                                            return true;
                                                        }
                                                        return true;
                                                    }
                                                },
                                                messages: {
                                                    dupemailvalidation: function (input) {
                                                        return input.attr("data-val-dupemailvalidation");
                                                    }
                                                }
                                            });

1 Answer, 1 is accepted

Sort by
0
Andrey
Top achievements
Rank 1
Veteran
answered on 12 Nov 2018, 04:57 PM

I've found the problem. The line

for (item in data) {

should be

for (var item in data) {

Thanks anyway!

Tags
Grid
Asked by
Andrey
Top achievements
Rank 1
Veteran
Answers by
Andrey
Top achievements
Rank 1
Veteran
Share this question
or