Once upon a time in Spain, you had to have a spare set of glasses in your car or face a fine; nowadays, it's only a recommendation. However, there are things you should be aware of.
For example, if you look at the back of your Spanish driving licence (and if you are a resident, you should have one by now) you will see column “12.” If it is blank, then you are registered as not needing glasses to drive.
However, if it is followed by “01,” it means that you should be wearing glasses to drive and failing to do so would mean a fine, even if you are wearing contact lenses at the time.
If it is followed by “01.02,” it means you use contact lenses and should have them in. Finally, if is has “01.06,” it means that you can drive wearing either.
So, unless the section 12 is empty, you could face a find of up to 200 euros.