The space between the bowling crease and the popping crease, which measures four feet in length, is the batsman's domain. If the batsman is found to be wandering beyond the popping crease, while the ball is in play, then he is buying himself trouble.
When the batsman ventures beyond the popping crease in an attempt to execute a stroke and in the process fails to connect the ball (either he completely misses the ball or the ball brushes some part of his pad or bat before proceeding towards the keeper), the wicket-keeper, on gathering the ball, shall whip the bails off.
In such an eventuality if the batsman is still found stranded outside the popping crease then the umpire shall rule the batsman out - stumped, but if the batsman has regained his crease on time then he survives the appeal.
A batsman cannot be given out stumped off a no ball, however an appeal for a stumping may be upheld on a wide delivery, although a wide is declared.
It must be noted here that the popping crease will be marked four feet from the bowling crease. If the bat or any part of his body is found to be on the line and not inside the line at the time when the stumps were being disturbed, then the batsman shall be ruled out.
It must also be noted that if the ball makes contact with the pad or the bat or even both and the batsman sets off for a run assuming that the ball has travelled beyond the reach of the keeper, but in reality the keeper happens to gather the ball and whips the bails off then in the event of the batsman being out of the safety of his crease, he shall be declared run out and not stumped.