Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript验证我的密码时出错_Javascript_If Statement_Types_Boolean_Character - Fatal编程技术网

使用Javascript验证我的密码时出错

使用Javascript验证我的密码时出错,javascript,if-statement,types,boolean,character,Javascript,If Statement,Types,Boolean,Character,我试图用一系列if语句和函数中的布尔变量检查用户输入的密码。我的if语句似乎没有修改布尔变量。有人能告诉我为什么吗 我试图使用(/[a-zA-z]/).test(pValue.charAt(0))作为布尔值,以查看第一个字符条目是小写字母还是大写字母,但这也不起作用 document.querySelector("#enter").addEventListener("click", validate); function validate(e) {

我试图用一系列if语句和函数中的布尔变量检查用户输入的密码。我的if语句似乎没有修改布尔变量。有人能告诉我为什么吗

我试图使用(/[a-zA-z]/).test(pValue.charAt(0))作为布尔值,以查看第一个字符条目是小写字母还是大写字母,但这也不起作用

document.querySelector("#enter").addEventListener("click", validate);

function validate(e) {
  
  var count = false;
  var firstChar = false;
  var hasNum = false;
  var special = false;
  var pValue = document.querySelector("#passwrd").value;
  var pLength = pValue.length;
  
  console.log(pValue);
  
  console.log(pLength);
  
  if(pLength > 4 && pLength <= 8) {
    
    count = true;
    
  }
  
  if(pValue.search(e.charCode === [65 - 90]) === 0) {
    
    firstChar = true;
    
  }
  
  console.log(firstChar);
  
  for(var j = 0; j < pLength; j++) {
    
    if(pValue.charAt(j) == "$" || pValue.charAt(j) == "%" || pValue.charAt(j) == "#") {
      
      special = true;
      
    }
    
  }
  
  for(var i = 0; i < pLength; i++) {
    
    if(!isNaN(pValue.charAt(i))) {
      
      hasNum = true;
      
    }
    
  }
  
  if(count && firstChar && hasNum && special) {
    
    document.querySelector("#show_word").textContent = pValue;
    
  }
  
}
document.querySelector(#enter”).addEventListener(“单击”,验证);
功能验证(e){
var计数=假;
var firstChar=false;
var hasNum=false;
var-special=false;
var pValue=document.querySelector(“#passwrd”).value;
var pLength=pValue.length;
console.log(pValue);
控制台日志(增压);
如果(增压>4和增压(&P)