Check if an input was loaded with jQuery

Asked

Viewed 496 times

0

I need to check if a text input has been loaded on the page and check if it is filled in, how can I do that? I’ve tried $('input'). on('load') but it doesn’t work, and the way the script is done I can’t make a $(Document).ready. Who knows a solution, please send it there

1 answer

2


I think what you want to do is this:

Do a test by removing the value value and then removing the page input!

How the test will be done on page loading, to do these tests. Copy the code and test on your machine!

var inputText = $('#teste').val();
if( inputText !== undefined) {
  
  if ( inputText != '' ) {
    alert('Foi carregado e está preenchido !');
  } else {
    alert('Foi carregado e não está preenchido!');  
  }
} else {
 alert('Não foi carregado!');      
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" value="texto teste" id="teste" />

  • Good, that helped me. Thanks

  • If that’s what you wanted then mark the answer as right! ;)

Browser other questions tagged

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