What is the best approach to handle new validation for existing records where duplicate IDs exist?

Currently I have a form where users can enter in the same ID (text) for each new record they create. I now want to add validation so that duplicate ID’s cannot exist going forward.
Some of these records are locked and cannot be edited, so …