-1
我正在尋找完成寫入輸入後按Enter鍵的方式,我正在掃描輸入中的代碼條,但在代碼插入輸入後我要自動按輸入並呼叫我的功能。這是我對我的輸入代碼:我掃描了一個CodeBar後按Enter鍵
<div class="form-group">
@Html.LabelFor(model => model.Id_Componente, "Id_Componente", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input class="form-control" type="text" id="Id_Componente" name="Id_Componente" autofocus="autofocus" onkeypress="FunctionP(event)" />
@Html.ValidationMessageFor(model => model.Id_Componente, "", new { @class = "text-danger" })
</div>
</div>
但其唯一的工作,當我按在鍵盤上輸入,我想要做的東西后,我掃描了條形碼的自動調用我的函數:FunctionP(事件)。對不起我的英語不好。
您可能可以使用輸入事件和去抖動,但是,我建議您查看掃描儀的文檔,我以前使用的文檔可以配置爲在輸入後導致輸入按鍵。 –
許多掃描儀通常可配置爲在掃描後可選地添加終止字符(通常爲CR)。可能比軟件解決方案更容易 – Tibrogargan