[英]Javascript error : Message: Expected ')'
I am getting a javascript error below, but I can't seem to find the problem: 我在下面收到一个javascript错误,但我似乎无法找到问题:
*Message: Expected ')' Line: 431 Char: 220 Code: 0 *消息:预期')'行:431字符:220代码:0
URI: http://mywebsite/CustomerLogin.aspx*
Line 431 is this javascript line: 第431行是这个javascript行:
<script language='Javascript'>
var varDateNow = new Date();
var varTimeNow = varDateNow.getTime();
var varAlertTime = document.getElementById('cphTopContent_AlertTime').value;
if(varTimeNow - varAlertTime < 1500)
{alert('2' values you entered were not valid:\n\nLog In - This value requires at least 6 characters. \nPassword - This value requires at least 4 characters. \n');}
</script>
What is causing the javascript error? 是什么导致javascript错误?
You have a missing open quote. 你有一个缺失的公开报价。 Try taking out the close quote after the
2
in the alert. 尝试在警报中的
2
后取出近距离报价。 Here's what happened behind the scenes: Since you closed the quotes after the 2, you're actually opening a new set of quotes at the end of the line after the \\n
. 这是幕后发生的事情:既然你在2之后关闭了引号,你实际上是在
\\n
之后的行尾打开一组新的引号。 So the compiler interprets everything following that point as a string, and thus it never finds the closing parenthesis. 因此编译器将该点后面的所有内容解释为字符串,因此它永远不会找到右括号。
<script language='Javascript'>
var varDateNow = new Date();
var varTimeNow = varDateNow.getTime();
var varAlertTime = document.getElementById('cphTopContent_AlertTime').value;
if(varTimeNow - varAlertTime < 1500)
{alert('2 values you entered were not valid:\n\nLog In - This value requires at least 6 characters. \nPassword - This value requires at least 4 characters. \n');}
</script>
{alert('2' values you entered were not valid:\n\nLog In - This value requires at least 6 characters. \nPassword - This value requires at least 4 characters. \n');}
Should be 应该
{ alert("2 values you entered were not valid:\n\nLog In - This valid requires at least 6 characters.\nPassword - This value requires at least 4 charactersn\n"); }
You messed up a few quotes, so the bracket that should end alert() was actually a string. 你搞砸了一些引号,所以应该结束alert()的括号实际上是一个字符串。
The alert message must be a string. 警报消息必须是字符串。 Hence, after the '2', it just doesn't understand what you want to do with all the chars and stuff.
因此,在'2'之后,它只是不明白你想要对所有的字符和东西做什么。
alert("blah blah '2' more blah and blah " + variableSomething + "finalBlah");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.