简体   繁体   English

我该如何修正“预期结单”?

[英]How do I fix Expected end of Statement?

How would I fix,"Expected End Of Statement" in the code below? 如何在下面的代码中修复“预期的语句结尾”?

  <script type="text/javascript">
function substitute() {
  var myValue = document.getElementById('myTextBox').value;

  if (myValue.length === 0) {
    alert('Please enter a real value in the text box!');
    return;
  }
  var myTitle = document.getElementById('title');
  myTitle.innerHTML = myValue;

}
</script>

It keeps telling me line 57 which is this line: 它不断告诉我第57行,这行是:

  <input type="submit" value="Click Me" onClick="substitute();">

Here is the complete HTA link: http://pastebin.com/fMg5e4RN 这是完整的HTA链接: http : //pastebin.com/fMg5e4RN

Use <form onsubmit="return substitute()" and return true or false depending on validation. 使用<form onsubmit="return substitute()"并根据验证结果返回true或false。 Remove type="javascript" or fix it as text/javascript 删除type =“ javascript”或将其修复为text / javascript

<script type="text/javascript">
function substitute() {
  var myValue = document.getElementById('myTextBox').value;

  if (myValue.length === 0) {
    alert('Please enter a real value in the text box!');
    return false;
  }
  // not sure what the following two lines are for
  var myTitle = document.getElementById('title');
  myTitle.innerHTML = myValue;
  return true; // allow submit

}
</script>

and use 和使用

<form action="some action"  onsubmit="return substitute();">
  <input type="text" id="myTextBox"/>
  <input type="submit" value="Click Me" />
 </form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复“预期在箭头函数末尾返回一个值”警告? - How do I fix "Expected to return a value at the end of arrow function" warning? 如何修复 Discord.js 中的“Declaration or statement expected.ts(1128)”? - How do I fix "Declaration or statement expected. ts(1128)" in Discord.js? 如何修复此非法中断声明? - How do I fix this Illegal break statement? 如何在带有文本的 if 语句中修复“缺少;在语句之前” - How do I fix "Missing ; before statement" in a if statement with text 如何修复声明或语句预期错误 - How to fix declaration or statement expected error 为什么我的预期 JSON 文字为“null”,我该如何解决? - Why is my expected JSON literal 'null', and how do I fix it? 无论 if 语句是否为真,我如何向前端发送响应 - How do i send a response to the front end whether or not the if statement is true 预期在 reactjs 上的箭头函数末尾返回一个值如何修复此错误? - Expected to return a value at the end of arrow function on reactjs how to fix this error? 如何修复预期在反应 function 组件结束时返回值的 linter? - How to fix linter expected to return a value at the end of react function component? 错误“0: &#39;Open&#39; is not defined”和“SCRIPT1005: SCRIPT1005: Expected &#39;(&#39;” 我该如何修复这些错误? - Errors "0: 'Open' is not defined" and "SCRIPT1005: SCRIPT1005: Expected '('" How do I fix these errors?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM