<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>2.13.JavaScript.条件语句</title>
</head>
<body>
<script type="text/javascript">

/*
//if else语句
if( 100 > 10 ){
document.write("真");
}else{
document.write("假");
}
*/
//

function checkChange(){
var username = document.getElementById("username");//获取到html节点
if( username.value == ""){
alert(
"用户名不能为空");
}
else if( username.value == "admin" || username.value == "xiaozhanga4"){
alert(
"恭喜你," + username.value);
}
else{
alert(
"用户名错误");
}

}

</script>

<form method="post" action="">
<input type="text" name="username" id="username"/>
<input type="submit" value="提交" onclick="checkChange();"/>
</form>


</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-02-10
  • 2018-02-08
  • 2022-12-23
  • 2021-06-16
猜你喜欢
  • 2021-07-31
  • 2022-12-23
  • 2021-10-19
  • 2021-05-28
  • 2021-08-03
  • 2021-11-24
相关资源
相似解决方案