دنبال کننده ها

۱۳۹۶ اسفند ۱۱, جمعه

javascript - How to check if the Array has Duplicates column values

[ad_1]



On ASP.NET MVC Page, I am loading the Excel Sheets data into object as below.



var sovData = $.csv.toObjects(importDataFromFiles[1].data);


Here this is coming as Array as below.



AccountNum: "Acc1", LocNum: "1", LocName: "Loc1", CountryCode: "US"
AccountNum: "Acc1", LocNum: "1", LocName: "Loc1", CountryCode: "US"
AccountNum: "Acc1", LocNum: "1", LocName: "Loc2", CountryCode: "UK"
AccountNum: "Acc1", LocNum: "1", LocName: "Loc3", CountryCode: "US"


Here AccountNum, locNum, LocName and CountryCode are the Columns on e Excel Sheet. The moment User selects the Excel File from UI and click on the Submit button, I do the validations.



Here LocName value should be unique. I need to display the validation error message if the LocName is not unique.
For Example: Here Loc1 is repeated.



What is the best way to check if LocName has Duplicates or not?




[ad_2]

لینک منبع