Can drinking water prevent nighttime leg cramps?

Dehydration can be a cause of leg cramps therefore, drinking water can help to prevent them. Sitting for long periods of time and not getting enough potassium can also cause leg cramps.