Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
Remove border outline when key stroked with javscript or css

Can anyone point me in the right direction for my problem. I wrote a rule that will out line my input box when there is no value submitted. But now would like to remove the red outline when I start typing in the input box. Suggestions?

enter image description here

CSS

  .placeholder-red-text {
  border: 1px solid #ff0000 !important;
}

JS

return x.classList.add('placeholder-red-text');

HTML

<input id="red-border-error"></input>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use another attribute of your input to set the style, i can think of three simple examples:

1: Make the input required and check if the input is valid

.foo { outline: 2px }
.foo:valid { outline: 0 }

and in your html

<input class="foo" required>

2: Do the same with a data attribute and some js like this

const fooEl = document.querySelector('.foo')

fooEl.addEventListener('input', (e) => {
  fooEl.setAttribute('data-foo', e.target.value)
})
.foo {
  outline: 2px yellow solid;
}

.foo:not([data-foo=""]) {
  outline: 0;
}
<input type="text" class="foo" data-foo="">

3: Same as before but setting a new class, or just setting a boolean value for the data-attribute instead of the value..

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda