使用HTMLService创建的密码输入字段将丢失type = password

时间:2012-07-01 16:04:36

标签: google-apps-script google-sites google-caja

我正在创建一个密码重置表单,供使用Google Apps for Education的学校的员工使用。我正在使用HTMLService API导入html文件并将其用作模板。该文件的一部分是此表:

  <table id=passwords>
    <tr>
      <td>New Password</td>
      <td>
        <input name='password1' id='password1' type='password'/>
      </td>
    </tr>
    <tr>
      <td>Confirm New Password</td>
      <td>
        <input name='password2' id='password2' type='password'/>
      </td>
    </tr>
  </table>

当我在Google协作平台页面上将其显示为小工具时,type='password'会从html中丢失,因此当用户输入密码时,密码不会被隐藏:

  <table id="passwords-caja-guest-0___">
    <tbody><tr>
      <td>New Password</td>
      <td>
        <input autocomplete="off" id="password1-caja-guest-0___" name="password1">
      </td>
    </tr>
    <tr>
      <td>Confirm New Password</td>
      <td>
        <input autocomplete="off" id="password2-caja-guest-0___" name="password2">
      </td>
    </tr>
  </tbody></table>

我可以转而使用UIService,它有一个密码输入小部件可以隐藏密码,但是那些在我之后维护网站的人也必须学习UIService相当冗长的API。

所以,我正在寻找有关如何在此上下文中隐藏密码输入的想法(即,只需在用户输入密码时显示星号或项目符号)。

1 个答案:

答案 0 :(得分:4)

恭喜!您已经在新的HtmlService上提交了第一个错误:)。

似乎在清理步骤中丢失了type = password。它的归档为bug 1487

作为一种解决方法,今天工作正常。

<input name='password1' id='password1' />
<script>document.getElementById('password1').type='password'</script>

也就是说,在JavaScript中自己设置类型是有效的。这只是一个临时的解决方法;我们将尽快修复底层错误。谢谢你的报告。

更新:Caja中已经修复了底层错误,我们将在下一个Apps脚本版本中将其解决。