Limit switch self triggering when L298 driver is used with motor

I have a conveyor system run by a 12 V brushed geared motor controlled by a L298 driver. Two limit switches at either end of the conveyor frame notify the Arduino Uno about the positions so the motor can reverse itself to alter direction. The driver is controlled by the Uno as well. However when the motor starts working either of the limit switches get suddenly triggered without getting actually pressed and the motor switches direction. Serial monitor show a that either of the switches have been triggered for a fraction of a second. However this problem does not occur when the motor is disconnected. Is this caused by stray capacitance?
Please clarify this.
Thank-you.

Do you have pull up (or pull down) resistors in place?

Hi ,

Sounds like ElectroMagnetic Interference (EMI)

This page should help: http://arduino-info.wikispaces.com/Arduino-Project-Planning-Electrical