Javascript 敏感的扫描仪问题。防止双重扫描
我有一个用户扫描条形码并提交表单的应用程序。问题是,扫描程序有时非常敏感,它会进行双重扫描,因此要么不是XXX预期值为XXXXXX,然后表单提交,要么表单快速连续提交两次。我想以某种方式添加一些暂停条件,以防止敏感的双重扫描。有什么想法吗 现行代码Javascript 敏感的扫描仪问题。防止双重扫描,javascript,asp-classic,Javascript,Asp Classic,我有一个用户扫描条形码并提交表单的应用程序。问题是,扫描程序有时非常敏感,它会进行双重扫描,因此要么不是XXX预期值为XXXXXX,然后表单提交,要么表单快速连续提交两次。我想以某种方式添加一些暂停条件,以防止敏感的双重扫描。有什么想法吗 现行代码 <script> function validateForm(form) { //This is the name of the function if (form.wonumber.va
<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%> <span class="style1 style2 style10">
</form>
函数validateForm(form){//这是函数的名称
如果(form.wonumber.value==“OP”){//,则检查以确保字段不为空
警报(“无法提交”);//通知用户空字段
form.wonumber.value=“”
return false;//这将阻止提交表单
}
返回真值
}
将零件扫描到外部;
您的OP有很多问题。我在本例中所做的是清理标记,删除没有意义的内容,并编写一些事件处理程序,使您的
在第一次更改后成为只读。我相信这会奏效,因为我认为扫描仪就像键盘一样。如果不起作用,请告诉我
<!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 <%=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>
函数validateForm(表单){
如果(form.wonumber.value==“OP”){
警告(“不能提交”);
form.wonumber.value=“”;
返回false;
}
返回true;
}
将零件扫描到外部;
胡萝卜
重置
我认为您提供的代码片段并不能说明全部情况。你会编辑你的原始帖子并插入完整的代码吗?更新原始帖子以包含完整的表单代码。如果你从读者那里获得的字符数超过了最大字符数,是否可以简单地清除表单?