Support multiple login forms on a page

Thanks to Jeffrey Guo for contributing.