Legal Shots

On all shots (except on the break and when the table is open), the shooter must hit one of his group of balls first and:
  1. Pocket a numbered ball
  2. Cause the cue ball or any numbered ball to contact a rail
And of course if either one of the conditions fail on the shot, the player loses his/her turn.

From 1999 World Standardized Rules of 8-Ball