The appropriate dress-code for a day at the races depends largely on the enclosure you plan on patronising. In general the rule of the thumb is: the more expensive the ticket, the more formal the dress. However, there are certain racing events, such as the ladies days, which require even the holders of cheap tickets to dress up.
The most stringent dress-code applies to spectators situated in the Members/Club/or Premier Enclosure (note: titles of enclosures may vary from track to track). In this enclosure you are required to wear formal wear; meaning jacket and tie for the men (unless a special occasion, like the Royal Ascot for example, which usually calls for a full morning suit), and heels, decent dresses and if needed magnificent hats for the ladies.
The Tattersalls/Grandstand/or Paddock Enclosure is usually satisfied with smart casual dress. On certain dates and in certain venues however, jeans and trainers (as long as they are nice) are allowed in this enclosure. As mentioned before, it is only on special occasions that Tattersalls (or equivalent) ticket holders are asked to appear in more formal costume.
Silver Ring/Course/or Picnic ticket holders are free to arrive in casual dress, bring rugs and food to sprawl on the lawn and make a lovely and relaxing occasion of a day at the races. You may of course arrive in an outrageous outfit to make your day even more memorable.