The each is a useful way to process those values, and add their values to a new array

Checking for duplicates is just a matter of looping backwards through the array, and using Array.indexOf() to check if the value exists at some earlier part of the array.

In regards to the error message, if you're using jQuery [validation then you can use [url="http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage"]addMethod](http://docs.jquery.com/Plugins/validation) for the checking code, so that an error message is automatically placed where needed.