Yes, both are correct, but the meanings are different. "The elder" would be the older of two people. "The elderly" would comprise all of the elderly people in the area being discussed.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.