你这个代码 reform.password2 这种写法只能在 IE 上用,
正确的标准的写法是
var form = document.getElementsByName('reform')[0];
var password2 = document.getElementsByName('password2')[0];
如果你使用像 Firefox 或 Google Chrome 来运行你原来的代码只能得到 JS 错误。
其实你是没有学会如何在浏览器中调试 debug 你的代码,如果是 Google Chrome 在打开网页中按 F12,然后在下面的 Source 标签页中找到你的源代码 js 文件,下断点一步一步的运行你的代码。
另外在 Console 标签页中查看 JS 错误。