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

289
Vistas
Using JavaScript reset removes format of phone field

I have 4 input fields for telephone numbers. They all have the [Phone] attribute in the model and the type="tel" in the HTML.

The fields look like this (904) 888-1234 when the form loads.

In model:

[Phone]
public string Phone {get;set;}

in HTML

<input type="tel" value="9048881234">
<button type="reset">reset</button>

When the user clicks the reset button, the formatting disappears (9048881234) and the form fails validation on submit.

Is there a way to reset the field so that it restores the format to (904) 888-1234?

Thanks,

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

0

Solution:

Before reset I store the field's value:

let phone = $("#Phone").val()

then clear it

$("#Phone").val("");

Then, after reset, I restore the value if it was not empty.

it (phone != ""){
    $("#Phone").val(phone);
}
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