【问题标题】:HTML + values out of two text forms两种文本形式的 HTML + 值
【发布时间】:2015-04-29 14:35:42
【问题描述】:

我需要一种方法从两个文本表单/字段中获取值并将它们放在一个隐藏的文本框中。

例如 密码1:水 密码2:12561

隐藏的密码表单现在应该包含“water12561”

我为什么需要这个? 我有一个带有 OTP(一次性密码)的 OTRS 登录,并希望使用 OTP 和存储在 mysql-DB/LDAP 中的密码来验证用户。通常的方法是,用户必须在一个字段中输入两个值,但我认为这不是一个好方法。由于这个原因,我想创建两个字段并将密码一起设置在一个字段中以将其提交给 perl 脚本。

顺便说一句 - 机器上没有安装 PHP。

【问题讨论】:

标签: html forms developer-tools otrs


【解决方案1】:

这是一个通过 JavaScript 工作的快速 sn-p。我使密码字段可见,因此您可以看到它正在工作。您只需隐藏密码字段即可满足您的要求。

document.getElementById("button").addEventListener("click", function(){
    concatFields();
});

function concatFields()
{
  var val1 = document.getElementById("input1").value;
  var val2 = document.getElementById("input2").value;
  var password = val1 + val2;

  document.getElementById("password").value = password;
}
<div>
  <label>input 1</label>
  <input id="input1" type="text" placeholder="add value here">
</div>
<div>
  <label>input 2</label>
  <input id="input2" type="text" placeholder="add value here">
</div>
<div>
  <label>password</label>
  <input id="password" type="password" placeholder="do not add value here">
</div>
<div>
  <input id="button" type="button" value="Concat field 1 and 2, then insert into field 3">
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 2011-09-28
    • 1970-01-01
    • 2011-02-03
    • 1970-01-01
    相关资源
    最近更新 更多