要求页面实现验证码功能,点击“注册”按钮后,无论是否完成注册,验证码都能够自动刷新
<script>
function validteCode()
{
var codes = new Array(4); //
var colors = new Array("Red","Green","Gray","Blue","Maroon","Aqua","Fuchsia","Lime","Olive","Silver");
for(var i=0;i < codes.length;i++)
{//
codes[i] = Math.floor(Math.random()*10);
}
var spans = document.getElementById("divCode").all;
for(var i=0;i<spans.length;i++)
{
spans[i].innerHTML=codes[i];
spans[i].style.color = colors[Math.floor(Math.random()*10)]; //
}
}
document.onload = validteCode();
</script>