【问题标题】:Sensitive Scanner Issue. Prevent Double Scan敏感的扫描仪问题。防止双重扫描
【发布时间】:2017-03-15 13:10:10
【问题描述】:

我有一个应用程序,用户扫描条形码并提交表单。麻烦的是,扫描仪非常敏感,有时会进行两次扫描,因此要么不是 XXX 预期的值,而是 XXXXXX 然后表单提交,或者表单快速连续提交两次。我想以某种方式添加一些暂停条件以防止敏感的双重扫描。有什么想法吗?

当前代码

       <script>
         function validateForm(form) { //This is the name of the function

        if (form.wonumber.value == "OP") { //This checks to make sure the field is not empty
        alert("Cant Submit."); //Informs user of empty field
        form.wonumber.value = ""
        return false; //This prevents the form from being submitted
        }
        return true
        }
        </SCRIPT>

    <form action="outer.asp" method="post" name="form100" id="form100" onSubmit="return validateForm(this)">
    <div align="center">
    <span class="style1 style4 style8">
    Scan Parts into Outer <%=request.querystring("id")%>;</span>  
    <p class="style1 style2">
     <input name="wonumber" type="text" id="wonumber" style="height:80px;font-size:50pt;" onChange="return validateForm(this)" size="7">
   </p>
    <p class="style1 style10"><%=description1%>&nbsp;<span class="style1 style2 style10">
  </form>

【问题讨论】:

  • 我不认为您提供的代码 sn-p 说明了整个故事。你会编辑你的原始帖子并插入整个代码吗?
  • 更新了原始帖子以包含整个表单代码。
  • 如果您从阅读器获得的字符数超过最大数量,是否可以简单地清除表单?

标签: javascript asp-classic


【解决方案1】:

您的 OP 有很多问题。我为这个例子所做的是清理你的标记,删除没有意义的东西,并编写一些事件处理程序,使你的&lt;input&gt; 在第一次更改后只读。我相信这会奏效,因为我认为扫描仪就像键盘一样。如果它不起作用,请告诉我。

<!doctype html>
<html>
    <head>
        <script type="text/javascript">
            function validateForm(form) {
                if (form.wonumber.value == "OP") {
                    alert("Cant Submit.");
                    form.wonumber.value = "";
                    return false;
                }
                return true;
            }
        </script>
    </head>
    <body>
        <form action="outer.asp" method="post" name="form100" id="form100" onSubmit="return validateForm(this)">
            <span class="style1 style4 style8">Scan Parts into Outer <%= server.htmlencode(request.querystring("id")) %>;</span>
            <input name="wonumber" type="text" id="wonumber" style="height:80px;font-size:50pt;" size="7" onchange="this.readOnly=true">
            <p><%=description1%></p>            
            <button type="button" onclick="form.wonumber.value='carrot'">Carrot</button><br>
            <button type="reset" onclick="form.wonumber.readOnly=false">Reset</button>
        </form>
    </body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-05
    • 2014-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多