How can I change the value of the playhead in the input?

  • 0
    https://codepen.io/SeraphimEvil/pen/jypgjN
    As soon as the focus is in the field, the placeholder should change to any other character from "+7 (___) ___-__-__" to "Your number", and when the focus is not in the field, it changes back.
    JavaScript Cora Matthews, Mar 23, 2019

  • 2 Answers
  • 0
    phoneInput.addEventListener('focus', () => {
    phoneInput.placeholder = 'Ваш номер'
    })

    phoneInput.addEventListener('blur', () => {
    phoneInput.placeholder = '+7 (___)___-__-__'
    })
    Anonymous

  • 0
    this option helped
    phoneInput.addEventListener('focus', () => {
    phoneInput.setAttribute('placeholder', '+7 (___)___-__-__')
    });

    phoneInput.addEventListener('blur', () => {
    phoneInput.setAttribute('placeholder', 'Ваш номер телефона')
    });
    Rhys Bishop

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!