I don't believe it is "officially" possible to construct a custom login page like you describe, however you may start by following a tutorial that demonstrates how to hack the official login page C:Program FilesTableauTableau Server9.0vizportalclientpubliclanguage> and create a custom HTML/JS script on it.
Typically, instructions focus on adding background, colour, etc., rather than complex functions, so you'll have to start from scratch and risk corrupting the file. This is, in my opinion, one of the greatest tutorials.