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

194
Visualizações
need to check input form if user upload the file or not with javascript

i have input form to upload you file and submitting that file(method = post) i need to cheack if user upload the image or not. if not should display error message and return false. but in my case return false don't working

my code

const jobs = document.getElementById("jobImage");
const error = document.getElementById("Error");

my function

function func(){
    if(jobs.value < 1){    
     console.log("1")
     error.style.display = "block";
     error.textContent = "Pleas upload your image";
     setTimeout(function(){ window.location.reload(); },5000);
      return false
    }
        
}

when i use my function its return true not false

<div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <button  type="submit" value="Save" class="btn btn-default" id="save" onclick="func()"><a href="www.google.com">Go now</a></button>
        </div>
    </div>
</div>

best regards

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you must change if to :

if( jobs.files.length == 0 ){
    ...
}
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