我正在尝试验证表单但是每当我点击提交按钮时它都会显示' ReferenceError:check_text未定义'即使变量存在于本地范围内。
Map<String, DocumentReference> userData = {
'usersReference': usersReference
};
Firestore.instance.collection('chats').add(userData).then((doc) {
doc.setData(userData);
});
以下是javascript代码,用于验证值。
<form class="input-text-box" method="post" action="">
<input type="text" id="uname" name="uname" placeholder="First Name" autocomplete="off" required>
<input type="text" id="ulastname" name="ulastname" placeholder="Last Name" autocomplete="off" required>
<input type="text" id="uuname" name="uuname" placeholder="Username" autocomplete="off" required>
<input type="text" id="contact" name="contact" placeholder="Contact" autocomplete="off" required>
<input type="email" id="email" name="uemail" placeholder="Email Address" autocomplete="off" required>
<input type="password" id="pass-1" name="upass1" placeholder="Password" autocomplete="off" required>
<input type="password" id="pass-2" name="upass2" placeholder="Confirm Password" autocomplete="off"required>
<input type="submit" value="Sign Up" id="submit-btn" onclick="validate()">
<p class="term-cond">By joining, you agree to our <a href="">Terms of Service</a> </p>
<p class="term-cond" style="margin:40px 0 0 65px;">Already a member? <a href="login.html">Sign In</a> </p>
</form>
我不明白如果我使用let而不是var,那么同名内部没有变量那么这个输出是合理的但是使用下面的方法为什么它没有被定义。如果我遗失了任何内容,请帮助我理解,因为我对javascript完全不熟悉。
答案 0 :(得分:1)
这里有一个拼写错误 int number1 = -1;
int number2 = -1;
char operator = ' ';
Scanner kb = new Scanner(System.in);
System.out.println("Enter what you want to calculate");
String line = kb.nextLine();
String[] pieces = line.split("\\s+");
boolean parsedInput = true;
if(pieces.length == 3)
{
number1 = pieces[0].matches("\\d+") ? Integer.parseInt(pieces[0]) : Integer.MAX_VALUE;
number2 = pieces[1].matches("\\d+") ? Integer.parseInt(pieces[1]) : (pieces[2].matches("\\d+") ? Integer.parseInt(pieces[2]) : Integer.MAX_VALUE);
operator = pieces[1].matches("\\*|\\-|\\+") ? pieces[1].charAt(0) : (pieces[2].matches("\\*|\\-|\\+") ? pieces[2].charAt(0) : ' ');
if(operator == ' ' || number1 == Integer.MAX_VALUE || number2 == Integer.MAX_VALUE)
parsedInput = false;
}
if(parsedInput)
System.out.println("Number 1: " + number1 + ", Number 2: " + number2 + ", Operator: " + operator);
else
System.out.println("Failed to parse: " + line);