Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Cómo formatear la entrada en html usando javascript

Cómo dar formato al texto de entrada en html, entrada de muestra: Hola, hola

Me gusta mostrar la entrada de esta manera

'Hola hola',

Cuando presiono enter, se mostrará automáticamente una comilla simple con una coma.

¿Cualquier sugerencia? Gracias.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puedes usar split y join

 const str = "Hi hello"; let output = ''; if(str) output = `'${str.split(" ").join("','")}',`; console.log(str);
about 4 years ago · Juan Pablo Isaza Report

0

A continuación, el texto se formatea y se devuelve al campo de entrada. Solo necesita un detector de eventos, una función que convierte el texto.

 const input = document.getElementById('watch'); input.addEventListener('keypress', function (e) { e.preventDefault(); if (e.key === 'Enter') { input.value = input.value.split(' ').map(s => `'${s}'`).toString() + ','; } return false; });
 <form> <input type="text" value="Hi World" id="watch"> </form>

about 4 years ago · Juan Pablo Isaza Report

0

 const string = 'abc' console.log(string.split(' ').map(str => `'${str}'`).toString() + ',')

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!