The rules of cricket
Law 26 (Bye and Leg bye)
If the ball, not being a No ball or a Wide, passes the striker without touching his bat or person, any runs completed by the batsmen or a boundary allowance shall be credited as Byes to the batting side.
2. Leg byes
(a) If a ball delivered by the bowler first strikes the person of the striker, runs shall be scored only if the umpire is satisfied that the striker has
either (i) attempted to play the ball with his bat,
or (ii) tried to avoid being hit by the ball.
If the umpire is satisfied that either of these conditions has been met, and the ball makes no subsequent contact with the bat, runs completed by the batsmen or a boundary allowance shall be credited to the batting side as in (b). Note, however, the provisions of Laws 34.3 (Ball lawfully struck more than once) and 34.4 (Runs permitted from ball lawfully struck more than once).
(b) The runs in (a) above shall,
(i) if the delivery is not a No ball, be scored as Leg byes.
(ii) if No ball has been called, be scored together with the penalty for the No ball as No ball extras.
3. Leg byes not to be awarded
If in the circumstances of 2(a) above the umpire considers that neither of the conditions (i) and (ii) therein has been met, then Leg byes will not be awarded. The batting side shall not be credited with any runs from that delivery apart from the one run penalty for a No ball if applicable. Moreover, no other penalties shall be awarded to the batting side when the ball is dead. See Law 42.17 (Penalty runs). The following procedure shall be adopted.
(a) If no run is attempted but the ball reaches the boundary, the umpire shall call and signal Dead ball, and disallow the boundary.
(b) If runs are attempted and if
(i) neither batsman is dismissed and the ball does not become dead for any other reason, the umpire shall call and signal Dead ball as soon as one run is completed or the ball reaches the boundary. The batsmen shall return to their original ends. The run or boundary shall be disallowed.
(ii) before one run is completed or the ball reaches the boundary, a batsman is dismissed, or the ball becomes dead for any other reason, all the provisions of the Laws will apply, except that no runs and no penalties shall be credited to the batting side, other than the penalty for a No ball if applicable.