However you planned to validate passwords, you validate the numbers created the same way rather than the actual passwords themselves. This can be an external Javascript file, but doesn't need to be. You'd have to first generate the numbers to put in the file yourself using the same function, of course.
If the site has to be secure enough that someone visiting can't see the numbers, then you HAVE to use server side scripting, and using an external JS file is false security. I've used this client-side method a few times (and it's somewhere on this site under my name from a few years ago) for minimum security for a website, but being able to get at the numbers still is a security flaw because someone can use a brute force method to find a match.
Lee