mengzekun

<body>
  <input type="text" id="username" />
  <p id="info"></p>
</body>

<script>
  var username = document.getElementById("username");
  var info = document.getElementById("info");
  username.onblur = function(){
  info.innerText = "";
  if(!username.value){
  info.innerText = "用户名不能为空";
  }
  if((username.value.length>0 && username.value.length<6) || username.value.length>20){
  info.innerText = "用户名不合法";
  }
  if(username.value.charCodeAt(0)>=65 && username.value.charCodeAt(0)<=90){
  info.innerText = "首字母不能大写";
  }
  }

</script>

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案