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

129
Vistas
Generando valor de entrada en 2 entradas llenas anteriores

Estoy tratando de generar un valor de entrada basado en 2 valores de entrada anteriores que completó el usuario. Primero es un nombre, el segundo es una fecha. Ahora necesito concatenar y formatear estos 2 valores y configurarlos para otra entrada.

Esto es lo que ya se me ocurrió:

  1. Oyente de eventos para la primera entrada: Nombre
  2. Dar formato al valor del Nombre
  3. Oyente de eventos para la segunda entrada: Fecha
  4. Dar formato al valor de fecha
  5. Concat estos 2 valores
  6. Establecer el valor de concat en la tercera entrada

El código que tengo hasta ahora:

 window.onload = function () { /* event listener for first input: Name */ document.getElementById('input_7_1').addEventListener('change', formatTitle); /* function to format the name value properly */ function formatTitle(){ document.getElementById('input_7_1').addEventListener("input", function(){ var title = document.getElementById('input_7_1').value; var formatTitle = title.replace(/\s+/g, ''); }); } /* event listener for second input: Date */ document.getElementById('input_7_3').addEventListener('change', formatDate); /* function to format the date value properly */ function formatDate(){ document.getElementById('input_7_3').addEventListener("input", function(){ var date = document.getElementById('input_7_3').value.replace(/\//g, ''); var formatDate = date.slice(0, -4); }); } /* concat both values in a variable */ var studentNummer = formatTitle.concat(formatDate); /* set value in the third input: Studentnummer */ function generateInput(){ document.getElementById('input_7_9').value = studentNummer; } }

Estoy casi allí por mi sentimiento. ¿Que me estoy perdiendo aqui?

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

0

Simplifiqué su código y lo hice mucho más comprensible. Prueba esto

 window.onload = function () { let studentNoField = document.getElementById('input_7_9'); let enteredDetails = {name: '', date: ''}; /* set value in the third input: Studentnummer */ function generateInput(){ let studentNumber = Object.values(enteredDetails).join(''); studentNoField.value = studentNumber; } /* event listener for first input: Name */ document.getElementById('input_7_1').addEventListener('input', function(event){ enteredDetails.name = event.target.value.replace(/\s+/g, ''); generateInput(); }); /* event listener for second input: Date */ document.getElementById('input_7_3').addEventListener('input', function(event){ enteredDetails.date = event.target.value.slice(0, -4); generateInput(); }); }
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