After js formats the bank card number, delete or increase the cursor in the middle to move to the last bit.

this is input, because the actual saved data is different from the displayed data, so model is not used. Now it can be formatted normally, four spaces in one space, but now the problem is that when you place the cursor somewhere in the middle to delete or add, the cursor automatically moves to the end, unable to delete and add normally in the middle.

     <input name="bank_account" label="" placeholder=" " type="text" :value="display_bank_account" @blur="handleBankCardBlur" @input="handleBankCardInput" />
     
     
     
     

 handleBankCardInput(val, event) {
      // 
      let caret = event.target.selectionStart
      // console.log(caret)
      // n
      let sp = (val.slice(0, caret).match(/\s/g) || []).length
      this.bank_account = val.replace(/\s/g, "")
      this.display_bank_account = val.replace(/\s/g, "").replace(/(\d{4})(?=\d)/g, "$1 ")
      // n
      let curSp = (this.display_bank_account.slice(0, caret).match(/\s/g) || []).length
      // console.log(curSp, sp)
      event.target.selectionStart = caret + curSp - sp
      event.target.selectionEnd = caret + curSp - sp
      console.info("caret", caret, "curSp", curSp, "sp", sp, "sum", caret + curSp - sp)
    },

tried to do the above work, but when testing on the PC side, sometimes it skips to the end, sometimes it is normal, when testing on the mobile side, the pointing of the cursor does not work, and it always jumps to the end.
Thank you.

Apr.03,2021

I have encountered this problem, have you solved it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8d12f-68899.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8d12f-68899.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?