Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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
user.js TypeError中的Javascript_uu2;Error:无法读取属性';价值';未定义的_Javascript_Articulate Storyline - Fatal编程技术网

user.js TypeError中的Javascript_uu2;Error:无法读取属性';价值';未定义的

user.js TypeError中的Javascript_uu2;Error:无法读取属性';价值';未定义的,javascript,articulate-storyline,Javascript,Articulate Storyline,这里有一些问题。 我想问你如何处理这个问题?事实上,我对Javascript还不熟悉。 先谢谢你 在控制台上看起来是这样的: user.js TypeError中的Javascript_uu2;Error:无法读取未定义的属性“value” 函数检查密码(表单){ var password=检查密码(password); var s_letters=“qwertyuiopasdfghjklzxcvnm”; var b_letters=“qwertyuioplkjhgfdsazxcvnm”; va

这里有一些问题。 我想问你如何处理这个问题?事实上,我对Javascript还不熟悉。 先谢谢你

在控制台上看起来是这样的:

user.js TypeError中的Javascript_uu2;Error:无法读取未定义的属性“value”

函数检查密码(表单){
var password=检查密码(password);
var s_letters=“qwertyuiopasdfghjklzxcvnm”;
var b_letters=“qwertyuioplkjhgfdsazxcvnm”;
var digits=“0123456789”;
var specials=“!@$%^&*(\-+=\\\\;/,:;[]{}”;
var为_s=假;
var为_b=假;
var为_d=假;
var为_sp=false;
对于(变量i=0;i=3)text=“Good”;
如果(password.length>=8&&rating<3)text=“Good”;
如果(password.length>=8&&rating>=3)text=“极好”;
如果(password.length>=6&&rating==1)text=“坏”;
否则,如果(password.length>=6&&rating>1&&rating<4)text=“Good”;
如果(password.length>=6&&rating==4)text=“极好”;
console.log(text);//警报在此处不适用。console.log允许您将数据导出到控制台以进行故障排除。
返回文本;
}
var player=GetPlayer();//获取播放器对象。
var myPassword=player.GetVar(“系统日期”);//获取myPassword的值
console.log(myPassword);
var newValue=checkPassword(myPassword);//运行函数并返回newValue
player.SetVar(“SystemDate”,newValue);//将newValue的值设置回故事情节

我稍微更改了您的函数,请尝试该函数(并向我们展示
SetValue
函数):

/@第一个错误-密码输入,而不是表单
功能检查密码(密码){
var expr,
评级=0,
规则={
//小写
“/[a-z]+/g”:假,
//大写字母
“/[A-Z]+/g”:假,
//数字
“/[0-9]+/g”:假,
//特殊符号
“/[^\w\s]/gi”:false
};
for(规则中的expr){
if(密码匹配(expr)){
//规则[expr]=true;//-可用于显示正确的无效消息
评级++;
}
}
返回
||password.length>=8&&评级>=3&&“优秀”
||password.length<6&&rating>=3&&Good
||password.length>=8&&rating<3&&Good
||password.length>=6&&rating>1&&rating<4&&Good
||“坏”;
}
//获取播放器对象。
var player=GetPlayer();
//获取myPassword的值
var myPassword=player.GetVar(“系统日期”);
//运行函数并返回newValue
var newValue=checkPassword(myPassword);
//将newValue的值设置回故事情节
//@第二个错误似乎在函数SetVar中
player.SetVar(“SystemDate”,newValue);

我稍微更改了您的函数,请尝试该函数(并向我们展示
SetValue
函数):

/@第一个错误-密码输入,而不是表单
功能检查密码(密码){
var expr,
评级=0,
规则={
//小写
“/[a-z]+/g”:假,
//大写字母
“/[A-Z]+/g”:假,
//数字
“/[0-9]+/g”:假,
//特殊符号
“/[^\w\s]/gi”:false
};
for(规则中的expr){
if(密码匹配(expr)){
//规则[expr]=true;//-可用于显示正确的无效消息
评级++;
}
}
返回
||password.length>=8&&评级>=3&&“优秀”
||password.length<6&&rating>=3&&Good
||password.length>=8&&rating<3&&Good
||password.length>=6&&rating>1&&rating<4&&Good
||“坏”;
}
//获取播放器对象。
var player=GetPlayer();
//获取myPassword的值
var myPassword=player.GetVar(“系统日期”);
//运行函数并返回newValue
var newValue=checkPassword(myPassword);
//将newValue的值设置回故事情节
//@第二个错误似乎在函数SetVar中
player.SetVar(“SystemDate”,newValue);

您能分享一下您的代码吗?当您试图访问
未定义的
对象上的
属性时,会出现此错误。例如:如果您有
元素.value
,元素应该是
未定义的
您要求javascript使用某个变量中的值,而该变量不是它创建的,就是它无法访问的(例如,如果您有一个函数,并且您试图访问另一个函数内部的变量,那么它们就不能看到彼此!)是的,当然!这里:var newValue=checkPassword(myPassword);您正在调用checkPassword(),密码来自我从您的评论中了解到的。因此,问题在这行:var password=form.password.value;尝试将函数标题更改为checkPassword(password),并从函数中删除第一行。正如我在这里看到的那样:粘贴代码时使用编辑器中的“code”按钮确实有助于您的观点-如果使用得当,您应该在代码所在的行中获得一些缩进。另外,底部有一个漂亮的预览框,你可以看到你的问题是什么样子的。你能分享你的代码吗?当您试图访问
un上的
value
属性时,会出现此错误
function checkPassword(form) {
  var password = checkPassword(password);
  var s_letters = "qwertyuiopasdfghjklzxcvbnm"; 
  var b_letters = "QWERTYUIOPLKJHGFDSAZXCVBNM"; 
  var digits = "0123456789"; 
  var specials = "!@#$%^&*()_-+=\|/.,:;[]{}"; 
  var is_s = false; 
  var is_b = false;
  var is_d = false; 
  var is_sp = false; 

  for (var i = 0; i < password.length; i++) {
    if (!is_s && s_letters.indexOf(password[i]) != -1) is_s = true;
    else if (!is_b && b_letters.indexOf(password[i]) != -1) is_b = true;
    else if (!is_d && digits.indexOf(password[i]) != -1) is_d = true;
    else if (!is_sp && specials.indexOf(password[i]) != -1) is_sp = true;
  }

  var rating = 0;
  var text = "";
  if (is_s) rating++; 
  if (is_b) rating++; // 
  if (is_d) rating++; // 
  if (is_sp) rating++; // 
  if (password.length < 6 && rating < 3) text = "Bad";
  else if (password.length < 6 && rating >= 3) text = "Good";
  else if (password.length >= 8 && rating < 3) text = "Good";
  else if (password.length >= 8 && rating >= 3) text = "Excellent";
  else if (password.length >= 6 && rating == 1) text = "Bad";
  else if (password.length >= 6 && rating > 1 && rating < 4) text = "Good";
  else if (password.length >= 6 && rating == 4) text = "Excellent";
  console.log(text); // Alert will not work for us here. Console.log allows you to export data to the console for troubleshooting.
  return text;
}

var player = GetPlayer(); // Gets the player object.
var myPassword = player.GetVar("SystemDate"); // Gets the value for myPassword
console.log(myPassword);
var newValue = checkPassword(myPassword); // Run the function and return to newValue
player.SetVar("SystemDate",newValue); // Set the value of newValue back to Storyline
// @first error - password input, not the form
function checkPassword (password) {
    var expr, 
        rating = 0, 
        rules = {
            // Lower case
            '/[a-z]+/g': false,
            // Upper case
            '/[A-Z]+/g': false,
            // Numbers
            '/[0-9]+/g': false,
            // Special symbols
            '/[^\w\s]/gi': false
        };

    for (expr in rules) {
        if (password.match(expr)) {
            // rules[expr] = true; // - can be used to show the proper message of invalidation
            rating++;
        }
    }

    return 
        || password.length >= 8 && rating >= 3 && "Excellent"
        || password.length < 6 && rating >= 3 && "Good"
        || password.length >= 8 && rating < 3 && "Good"
        || password.length >= 6 && rating > 1 && rating < 4 && "Good"
        || "Bad";
}

// Gets the player object.
var player = GetPlayer(); 
// Gets the value for myPassword
var myPassword = player.GetVar("SystemDate"); 
// Run the function and return to newValue
var newValue = checkPassword(myPassword); 
// Set the value of newValue back to Storyline
// @second error seems to be in the function SetVar
player.SetVar("SystemDate",newValue);