javascript 验证表单

<script language=javascript>
<!--
function SetFocus()
{
if (document.Login.UserName.value=="")
 document.Login.UserName.focus();
else
 document.Login.UserName.select();
}
function CheckForm()
{
 if(document.Login.UserName.value=="")
 {
  alert("请输入用户名!");
  document.Login.UserName.focus();
  return false;
 }
 if(document.Login.Password.value == "")
 {
  alert("请输入密码!");
  document.Login.Password.focus();
  return false;
 }
 if (document.Login.CheckCode.value==""){
       alert ("请输入您的验证码!");
       document.Login.CheckCode.focus();
       return(false);
    }
}

function CheckBrowser()
{
  var app=navigator.appName;
  var verStr=navigator.appVersion;
  if (app.indexOf('Netscape') != -1) {
    alert("友情提示:\n    你使用的是Netscape浏览器,可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
  }
  else if (app.indexOf('Microsoft') != -1) {
    if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1)
      alert("友情提示:\n    您的浏览器版本太低,可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
  }
}
//-->
</script>

posted @ 2006-05-15 17:12  大牛博客  阅读(326)  评论(0)    收藏  举报