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

249
Vistas
The text overflows outside container on entered Email

Have a code that user enters Email, the email gets stored in Variable and i call it later in a container. The problem is that if the email is longer it overflows through the container. How can i split it for example mail: " JohnDeer@gmail.com ", the JohnDeer to go on the first line and @gmail.com to go on the second line? What will be the best way to do it, to split it or to limit the characters?

Example

<div class="main">
<div id="main1">
<input class="user-input" id="input-id" placeholder="Email" onblur="main0(this)">
<div class="btn0" id="btn0id" onclick="main0()">Show Email</div>
</div>
<div id="main2">
<span id="name"></span>
</div>
</div>

CSS

.main{
text-align: center;
background: black;
width: 90%;
max-width:25em;
justify-content: center;
align-items: center;
border-radius: 1.5em;
border-color: white;
border-style: solid;
border-width: 0.1em;
box-shadow: 0 0 1em white;
box-sizing: border-box;
position: absolute;
z-index: 10;
}
body{
color:white;
}

JS

function main0(emailField){
var name=document.getElementById("input-id").value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (reg.test(emailField.value) == false) {
    document.getElementById("input-id").style.borderBottom = "0.2em solid darkred";
    setTimeout(function (){
        document.getElementById("input-id").style.removeProperty("borderBottom");
    },500);
} else {
        setTimeout(function () {
            document.getElementById("main1").style.display = "none";
                setTimeout(function () {
                    document.getElementById("main2").style.display = "block";
                    document.getElementById("name").innerHTML = name;
     }, 100);
   }, 100);
}
}

And for some reason idk why the removeProperty does not remove the border after seconds.

Edit: Also noticed that if you get the email format right, if you click anywhere on the screen it will go to the show email without clicking on the button. How can i fix that?

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

0

Fixed by adding this in CSS

overflow: hidden;
text-overflow: ellipsis;

This way if the email is longer than the container it will add " ... " and will not show the rest of the email.

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