True, it would be tricky to get all the rules of chess into a JS file (sounds like a worthwhile open source challenge to me!), but it wouldn't be so hard to expose the features of a chess program like Crafty through an API and do the check via AJAX.
Check out chess.js, https://github.com/jhlywa/chess.js, it does a pretty excellent job. The combination of chessboard.js and chess.js would result in a pretty sweet browser-based chess game.