Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda