A crossword grid is only valid if its white squares form a single connected region. If we represent the grid as a graph, with squares as nodes and edges representing adjacency, this is a graph connectivity question. We can answer this question with Depth-First Search (DFS).
Click squares to block them. Then run DFS and watch it go. Each square's border is colored when the DFS first enters it, and its interior is colored when the search exits it. As the number of movements increases, the color gets darker; so, a pale border around a dark interior means a square that was entered early and not finished until much later (that is, it has a deep subtree beneath it).
—
Time
earlylate
border — entered
interior — left
blocked square
never reached
tree edge (active path darker)
Call stack
empty
Counters
clock0
stack depth0
white squares0
reached0
regions—
Traversal order
square
d
f
depth
The mechanics
Starting square. The lexicographically smallest white square (topmost row, then leftmost column).
Neighbor order. Neighbors of (r,c) are visited in lexicographic order of their coordinates: (r−1,c), (r,c−1), (r,c+1), (r+1,c); that is up, left, right, down. This order is deterministic, so you can predict the whole traversal and test your knowledge of DFS.
Square labels. Each square is labeled with its enter number (top-left) and exit number (bottom-right).
The clock. Enter and exit numbers are tracked on a single counter, incremented on every entry and every exit. A grid with n reachable white squares ends at time 2n.
The parenthesis property. For any two squares, the enter-exit intervals [d,f] are either disjoint or one contains the other — never partially overlapping. Containment means one is a descendant of the other in the DFS tree.
The verdict. One search from one starting square reaches every white square if and only if the white squares are connected. Anything left uncolored is unreachable, and the grid is invalid.