How to know if the file input has something?

Asked

Viewed 253 times

1

Good morning, everybody, okay? I’m in bad shape...

People like I can know that the guy has selected some file from pc?

Type wanted to know this answer in true or false with jquery.

For example, it appears there: [NO FILE SELECTED] Then when the guy selects something like I know who he selects?

  • Put part of the code that has already been made to help with the implementation.

1 answer

0


Just make a check if the field has value. You can pick up by id country:

function checa(){
   var input_file = $("#file").val();
   
   if(input_file){ // retorna true se teve algum arquivo selecionado
      alert("arquivo selecionado");
   }else{
      alert("nenhum arquivo selecionado");
   }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="file" />
<br />
<input type="button" value="Verificar" onclick="checa()" />

This check is basic, works with input guy text also. Only check if there is value in the field.

  • toppppppppppppp

  • O man but changing the subject you know how I can cosnser a job with this/

  • @Optimusdesperate Dude, you have to search in classifieds.

  • ok I will search , but come here, web programmer is accepted only if you know framework?

  • I only know how to do everything by hand , and learn a framework for me now is to take a beating because my mother has already told me to work and show the money...

  • @This is too broad. Sometimes a company wants someone who knows Bootstrap, others don’t... some want jQuery, others don’t... it’s good to learn everything a little and get by with things it doesn’t dominate much. But the basic thing is to know Javascript, jQuery, CSS and HTML...

  • @Optimusdesperate And knowing a backend language like PHP (most required in the market today)

  • Yes, my current knowledge is: PHP,jquery, javascript(can read), object-oriented php(NO MVC pq learning mvc will take),html css, responsiveness with css.

  • much jquery use

  • @Optimusdesperate It improves and seeks to take freelance jobs that can give a $. Right here in the OS is a great place to learn. Try to answer the questions you know.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.