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

168
Vistas
Compare text input's value and default value and check if changes has only spaces

User changes the value of that text box.If user want to close form I must check if changes(recent.value)contains only spaces and if not - just close form, but if it has - alert("Do you realy want to exit without saving changes?")

$('.cancel-button').on('click', function () {
    if (recent.value != recent.defaultValue) {
        // if changes I must check - if this changes contains only spaces
    }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Look at below method isSpaceEqual, which removes spaces in data before comparing, returns true when the change is only spaces.

function isSpaceEqual(value1, value2) {
    value1 = String(value1 || "");
    value2 = String(value2 || "");
    return value1.replace(/[ \r\n]/g, "") === value2.replace(/[ \r\n]/g, "");
}
$('.cancel-button').on('click', function () {
    if (recent.value != recent.defaultValue) {
        // if changes I must check - if this changes contains only spaces
        if(isSpaceEqual(recent.value, recent.defaultValue)) {
            // change is only spaces, new line or carriage return
        } else {
            // actual change
        }
    }
});
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