js两次输入密码验证,可以参考如下代码:
<FORM METHOD=POST ACTION=""><input type="password" id="input1">
<input type="password" id="input2">
<input type="button" value="test" onclick="check()">
</FORM>
<script>
function check()
{
with(document.all){
if(input1.value!=input2.value)
{
alert("false")
input1.value = ""
input2.value = ""
}
}
}
</script>
JavaScript验证两次输入密码是否相同,通过去判断两次输入的密码是否相同来实现,
下面是html代码<FORM METHOD=POST ACTION="">
<input type="password" id="input1">
<input type="password" id="input2">
<input type="button" value="test"
onclick="check()">
</FORM>下面是javascript的代码<script>
function check()
{
with(document.all){
if(input1.value!=input2.value)
{
alert("false")
input1.value = ""
input2.value = ""
}
else document.forms[0].submit()
}