How close to an outlet box must a cable be supported?
There are two numbers, and which one applies depends on the box. NEC 2023 Section 334.30 requires nonmetallic sheathed cable to be supported and secured at intervals not exceeding 4.5 feet and within 12 inches of every outlet box, junction box, cabinet or fitting. Section 314.17(C) Exception adds the 8 inch rule: where a nonmetallic box is a single gang box not larger than 2.25 by 4 inches and does not have cable clamps, the cable is permitted to enter without being secured to the box, provided it is secured within 8 inches of the box measured along the sheath.
The 8 inch rule in practice
That is the rule behind the common blue single gang nail on box with no internal clamps. The cable is not clamped at the box, so the staple has to be within 8 inches. Move to a two gang nonmetallic box, or any box with integral clamps, and the exception no longer applies: the cable must be secured to the box by the clamp, and the 12 inch support requirement of 334.30 governs the first staple. That is why a cable landing in a two gang old work box has to have its clamp tightened even though the equivalent single gang install does not.
The other wiring methods
Section 320.30(B) requires armored cable to be secured within 12 inches of every outlet box or fitting and at intervals not exceeding 4.5 feet. Section 330.30(B) requires MC cable to be secured within 12 inches of every box, cabinet or fitting and at intervals not exceeding 6 feet. Section 340.30 for underground feeder cable and 336.30 for tray cable each have their own numbers. Metal raceways get 3 feet: 358.30(A) for EMT and 344.30(A) for rigid metal conduit both require support within 3 feet of each box or fitting.
Where the support rules relax
Section 334.30(B) allows unsupported NM cable in two situations that come up constantly on remodels. Cable fished between access points through concealed spaces where support is impracticable is permitted to be unsupported. Cable not more than 4.5 feet long from the last point of support may be unsupported where it enters a luminaire or equipment inside an accessible ceiling, provided the wiring method is not subject to physical damage. Section 314.23(H) covers boxes supported by conduit, and 320.30(D) has similar fished cable relief for armored cable.
Staple details that fail inspections
Section 334.30 requires the cable to be secured by staples, cable ties listed and identified for securement and support, straps, hangers or similar fittings designed and installed so as not to damage the cable. Overdriven staples that crush the jacket are a 334.30 violation on their own, and a flat cable stapled on edge is another. Section 300.4(D) requires cables run parallel to framing members to be kept 1.25 inches back from the nearest edge or protected by a steel plate, and that is a separate requirement from support.
Field takeaway
Twelve inches from the box for NM, AC and MC cable in the normal case, 8 inches when using a single gang nonmetallic box without clamps and not clamping the cable, and 3 feet for EMT and rigid conduit.