日期:2014-05-17  浏览次数:20596 次

小问题.急求

  .code
  {
  background-image:url(code.jpg);
  font-family:Arial;
  font-style:italic;
  color:Red;
  border:0;
  padding:2px 3px;
  letter-spacing:3px;
  font-weight:bolder;
  }
  .unchanged
  {
  border:0;
  }
   
   
  var code ; //??? ?????
  function createCode()
  { 
  code = "";
  var codeLength = 5;//??????
  var checkCode = document.getElementById("checkCode");
  var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');//????????????,?????????
   
  for(var i=0;i<codeLength;i++)
  {
   
   
  var charIndex = Math.floor(Math.random()*36);
  code +=selectChar[charIndex];
   
   
  }
// alert(code);
  if(checkCode)
  {
  checkCode.className="code";
  checkCode.value = code;
  }
   
  }
   
  function validate ()
  {
  var inputCode = document.getElementById("input1").value;
  if(inputCode.length <=0)
  {
return false;
  alert("Enter the verification code!");
createCode();
 
  }
 
  else if(inputCode != code )
  {
  return false;
alert("code Mistake!");
  createCode();//?????

  }
 
  else
  {
  alert("OK");
document.form.submit();
  }
   
  }



如何将<input name="text" type="text" class="unchanged" id="checkCode" style="width: 80px" />

这个东西打开的时候就显示出来呢?

------解决方案--------------------
在body里,写ONLOAD = createCode 不行吗?