将代码加在复选框的click事件中:if this.value=1 thisform.text1.passwordchar="" else thisform.text1.passwordchar="*"endif