大家好,小弟初来乍到。写一遮罩层,脑钝。望解决,谢过。
为了简单,我把代码主要部分贴出来
function show(){
......document.getElementById(‘最上面一层的ID’).innerHTML="....<input type='password' name='userpassowrd1'> <input type='userpassword' name='userpassword2'>"......
}
show()的作用是弹出遮罩层 以及背景层
然后写下面一段话
function check(){
if(document.getElementsByName("userpassword1").value ==document.getElementsByName("userpassword2").value)
{
alert("两次密码输入一致");
}
else
{
alert("两次密码输入不一致");
show();
}
}
然后小弟两个密码框不管输入什么 都显示密码一致 不执行show()\
然后将代码改成
if(document.getElementsByName("userpassword1").value ==document.getElementsByName("userpassword2").value)
{
alert("两次密码输入不一致");
}
else
{
alert("两次密码输入一致");
show();
}
}
弹出了不一致 但是执行了show
其他代码都没有问题 我都测试过了
求解 在此谢过
为了简单,我把代码主要部分贴出来
function show(){
......document.getElementById(‘最上面一层的ID’).innerHTML="....<input type='password' name='userpassowrd1'> <input type='userpassword' name='userpassword2'>"......
}
show()的作用是弹出遮罩层 以及背景层
然后写下面一段话
function check(){
if(document.getElementsByName("userpassword1").value ==document.getElementsByName("userpassword2").value)
{
alert("两次密码输入一致");
}
else
{
alert("两次密码输入不一致");
show();
}
}
然后小弟两个密码框不管输入什么 都显示密码一致 不执行show()\
然后将代码改成
if(document.getElementsByName("userpassword1").value ==document.getElementsByName("userpassword2").value)
{
alert("两次密码输入不一致");
}
else
{
alert("两次密码输入一致");
show();
}
}
弹出了不一致 但是执行了show
其他代码都没有问题 我都测试过了
求解 在此谢过
var a=document.getElementById("background");
a.style.display="";
a.style.filter ="Alpha(Opacity=50)";
document.getElementById("vista").style.display="";
document.getElementById("vista").innerHTML="<table style='color:White;font-size:20px;width:500px;height:50px;background-color:#0099FF'><tr style='margin:10px;'><td>网站注册</td><td align='right'><a onclick='hiden()'><img src='img/x.gif' /></a></td></tr></table><table style='margin:60px auto;'><tr><td>用户名</td><td><input type='text' name='userName'></td></tr><tr><td>密 码</td><td><input type='password' name='userpassword1' style='height:16px;width:150px'></td></tr><tr><td>重复密码</td><td><input type='password' name='userpassword2' style='height:16px;width:150px'></td><tr><tr align='center'><td><input type='submit' onclick='check()' value='注册'/></td><td ><input type='button' value='退出' onclick='hiden()'></td></tr></table>";
}
function hiden() {
document.getElementById("vista").style.display = "none";
document.getElementById("background").style.display="none";
}
function check(){
if(document.getElementsByName("userpassword1").value ==document.getElementsByName("userpassword2").value)
{
alert("两次密码输入不一致");
}
else
{
alert("两次密码输入一致");
show();
}
}
vista 为前景div ID
background 为背景div的ID
直接写到html中(visat)然后让其(visat)隐藏show的时候让他显示就行了,这样就能获取到值了
不然这样:
document.getElementsByName("userpassword1")[0].value==document.getElementsByName("userpassword2")[0].value
如果你的Name唯一应该也可以
{
alert("两次密码输入不一致");
return;
}
else
{
alert("两次密码输入一致");
show();
}
}
同在一个JS文件中
两个不同的函数 一个函数如何调用另外一个函数里面的控件 getelementById 貌似都没用