📌  相关文章
📜  如何使用javascript代码示例检查用户名是否已存在于数据库中

📅  最后修改于: 2022-03-11 15:01:21.585000             🧑  作者: Mango

代码示例2
function validacija() {

  let user = document.getElementById('user');
  let listOptions = document.querySelectorAll("#list option");


  if (user.value.length <= 20 && user.value.length >= 3) {} else {
    alert("Username has to be between 3-20 characters.")
  }


  for (let i = 0; i < listOptions.length; i++) {
    if (listOptions[i].value === user.value) {
      alert('The name already exist')
    }
  }
  return false;
}