檢測用戶輸入是否爲空

<input type="submit" value="登陸" name="submit" onClick="check();">

<script>
/* function check(){
  var username=document.getElementById("username").value;
  var password=document.getElementById("password").value;


   if(username!=""){
    if(password!=""){
     //alert("登陸成功!");
     location="list.php";
    }else{
     alert("密碼不能爲空");
    }
   }else{
    alert("用戶名不能爲空");
    return false;
   }
 
 }*/
</script>
相關文章
相關標籤/搜索