如何使用javascript将输入类型密码的值发送到另一个输入?

时间:2014-11-19 02:39:11

标签: javascript

如何使用javascript将输入类型密码的值发送到其他intup?

首先,将数据填入

<input type="text" onchange="updateInput_current_password(this.value)">

然后是

中的数据
<input type="text" name="current_password_for_check" id="current_password_for_check"/>  

将改变跟随,

但是当我申请使用

<input type="password" onchange="updateInput_current_password(this.value)">

为什么,值

<input type="text" name="current_password_for_check" id="current_password_for_check"/>

不改变?

我该怎么做?

<script type="text/javascript">
function updateInput_current_password(current_passwordvalue){
    document.getElementById("current_password_for_check").value = current_passwordvalue;
}
</script>


<input type="password" onchange="updateInput_current_password(this.value)">


<form id="current_password_send_value_fid">
    <input type="text" name="current_password_for_check" id="current_password_for_check"/>  
</form>

2 个答案:

答案 0 :(得分:0)

你应该这样做:

Demo

HTML:

<input type="password" />

的JavaScript:

var inpt = document.querySelctor('input[type="password"]');

inpt.onkeydown = function() {
    alert(inpt.value);
}

答案 1 :(得分:0)

您更改输入传递的事件

<input type="password" onkeydown="updateInput_current_password(this.value)" onkeyup="updateInput_current_password(this.value)" />