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

262
Views
deshabilitar la tecla enter en cuadros de texto específicos

Estaba buscando una manera de hacer esto, obtuve algunos scripts, pero ninguno de ellos funciona para mí.

Cuando presiono enter en mis cuadros de texto, no debería hacer nada.

He probado algunos scripts de JavaScript y jQuery, pero nada me funciona.

 $(document).ready(function() { $('#comment').keypress(function(event) { if (event.keyCode == 13) { event.preventDefault(); } }); $('#comment').keyup(function() { var txt = $('#comment').val(); $('#comment').val(txt.replace(/[\n\r]+/g, " ")); }); });
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Esto funciona para mí.

 $('textarea').keypress(function(event) { if (event.keyCode == 13) { event.preventDefault(); } });

jsviolín .

Su segunda pieza parece estar diseñada para capturar personas pegando en varias líneas. En ese caso, debe vincularlo a keyup paste .

over 4 years ago · Santiago Trujillo Report

0

Si desea evitar la tecla Intro para un cuadro de texto específico, use js en línea.

 <input type="text" onkeydown="return (event.keyCode!=13);"/>
over 4 years ago · Santiago Trujillo Report

0

Impide que el usuario presione Entrar en el cuadro de texto y aquí devuelvo falso , lo que impide que se envíe el formulario.

 $(document).ready(function() { // Stop user to press enter in textbox $("input:text").keypress(function(event) { if (event.keyCode == 13) { event.preventDefault(); return false; } }); });
over 4 years ago · Santiago Trujillo 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!