表单的检验校对checkform

<script language=javascript>
      function checkform(){
      //定义一个名为checkform的函数
      if(document.form1.user.value=="")
      //检查表单1中的user文本框的值是否为空
      {
      alert("用户名不能为空");
      //使用alert方法弹出提示框
      return false;
      }
      if(document.form1.upass.value!=document.form1.pass2.value)
      //检查表单1中的upass文本框的值和pass2文本框中的值是否不一样
      {
      alert("两次密码不一致,请检查后重新输入");
      //条件满足时,弹出相应的提示框
      return false;
      }
      }
      </script>

<form id="form1" name="form1"   onsubmit="return checkform();">

 

posted on 2020-03-07 23:05  sunyzone  阅读(1172)  评论(0)    收藏  举报

导航