Is there another way to check for duplicate value’s in array’s in javascript, other then just doing something like this? I can imagine that there is a shorter way, especially if you have to make sure multiple fields are unique?
It would be best to use nested for loops. Take a look at these search results, there are plenty of people who’ve written functions to do this (you can modify it to not remove the duplicates and display your message instead). Some of them can look quite different, but essentially they are mostly a for loop inside another for loop:
That’s right, some browsers don’t have their own indexOf method, which is why the page that was linked to also provides compatibility code for those browsers.