iT邦幫忙

0

(已解決)網頁刷條碼時無法保留文字

reed 2022-09-13 18:17:551130 瀏覽
  • 分享至 

  • xImage

嘗試寫一個網頁介面,其中一個欄位是給人員刷條碼
但在網頁上刷了條碼,文字卻無法停留在上面,一下就消失
網頁介面如下
https://ithelp.ithome.com.tw/upload/images/20220913/20148072YFixrCQ5RF.png
html的寫法如下

  <div class="form-group">
    <label for="process_id">ISBN:</label>
    <input type="text" class="form-control" id="ISBN_no">
  </div>

不知是甚麼原因造成閃屏,文字無法停留並輸入
感謝諸位大神回復

在input type=text裡加一onkeypress事件,如果遇到event.key.which === 13 ,則在事件處理的第一行加上 event.preventDefault();
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
㊣浩瀚星空㊣
iT邦大神 1 級 ‧ 2022-09-13 21:38:52
最佳解答

檢查你的html是否有使用 form 或是 submit 的相關元件。
兇手就是它。

reed iT邦新手 5 級 ‧ 2022-09-14 10:01:53 檢舉

感謝 ㊣浩瀚星空㊣,我把form改成body問題就解決啦~

回錯人了...

我要發表回答

立即登入回答