javascript - input cursor position is misplaced
我想大声告诉你
我想大声告诉你 2017-05-18 11:01:58
0
1
506

In the input input box on the mobile phone, use the following code to set the format of the mobile phone number to "000 0000 0000", and add a space in the middle of the mobile phone number.

if (mValue != '') {
      let mLength = mValue.length;
      if (mLength <= 3) {
        return mValue;
      } else {
        if (mLength <= 7) {
          return mValue.substring(0, 3) + ' ' + mValue.substring(3, mLength)
        } else {
          return mValue.substring(0, 3) + ' ' + mValue.substring(3, 7) + ' ' + mValue.substring(7, 11)
        }
      }
    }

Personal test is normal, but it will appear on Huawei mate9. Every time when entering the third number, when adding a space, it will be displayed that the space has been added normally, but the cursor is in front of the space and the number is entered again. The cursor is always in front of the last number.

我想大声告诉你
我想大声告诉你

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!