Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

331
Vistas
cleaning DOM of JS, because of livewire

i have a project that have combination of: php(laravel) in backend AND front end of javascript+css+html.

my strategy:

  1. I have an input for inserting password(input type: password).
  2. I have an icon for show, password digits, when user click on that icon.
  3. handle that process, by "onclick" event inside "icon" element: when user clicks on "eye icon", javascript changes the property of input tag, the type="password" to type="text",(user can see her/his inserted password digits ).

MY PROBLEM:

but, because of livewire property inside input tag ,after of showing password digits, by typing more password digits, password numbers being convert to * again!

livewire property that used inside input tag: wire:model.debounce.700ms="password" .

I think, it is because of that: the livewire, reloads the input tag.

Anyone knows the solution?

the div, that contains input password and eye icon(for clicking by user for show password digits):

<div class="o-form__field-frame o-form__field-frame--password  @error('password') has-error @enderror">
<input type="password" wire:model.debounce.700ms="password" id="password" value="{{$password}}" placeholder="PLEASE INSERT YOUR PASSWORD" class="o-form__field">
<i class='fa fa-eye hSh_eye_show_pass' onclick='showPass()'></i>
</div>

the function that handle that:

//for show pass:
function showPass(){
document.getElementById('password').type="text";
}

 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Since livewire changes the input stuff you could have a second input of type text hidden and if the user clicks the other input is shown instead:

// used for being able to apply the inputs values correctly..
// u can omit that this is only for making code snippet working..
let pwHidden = true

function togglePassVisibility() {
   const passVisible = document.getElementById('password-visible')
   const passHidden = document.getElementById('password-hidden')
   
   // toggle the .hidden class on both..
   
   passVisible.classList.toggle('hidden')
   passHidden.classList.toggle('hidden')
   
   // make this code snippet work since I cannot access {{$password}}
   // you can omit this..
   if(pwHidden) {
      passVisible.value = passHidden.value
   } else {
     passHidden.value = passVisible.value
   }
   
   pwHidden = !pwHidden
   
}
.hidden {
   display: none;
}
<!-- you need ofc to pass {{$password}} as value to make it work in your environment. -->
<input type="text" class="hidden" id="password-visible"></input>
<input type="password" id="password-hidden"></input>
<button onClick="togglePassVisibility()">toggle</button>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda