Does the fan say its designed to work with a speed control, and does the dimmer say its designed to drive a motor of the type your using? If not, its not only against the National Electrical Code, but its also a fire hazard.
Fan motors are designed to use the air flow of the fan for cooling. As a fan is decreased in speed using a dimmer, its air flow also decreases, but the heat it produces decreases at a lesser rate because the fan can become less efficient at moving air at lower speeds when used with dimmers. This causes it to heat up, and it can catch on fire. This isn't a problem for fans designed for speed controls, but a big problem for those not designed for them.