title: javascript div disappear when input deleted
body: <p>I have a question concerning the following :</p>
  
  <p>I have a div with <code>display:none</code>. This div appears once a user types text into an input field (with the jQuery show() method). Everything works fine, but once I delete the text typed into the input field, I would like the DIV to disappear again. My attempt:</p>
  
  <p>use another <code>function</code> with the jQuery <code>hide()</code> function if the input is empty, but it prevents the function using show() to be triggered (since the input is obviously empty by default).</p>
  
  <p>Any ideas would be much appreciated !</p>
  
  <p>Here is my script:</p>
  
  <pre><code>function password1Security()
  
  {
  var pwd1 = document.getElementById("password1");
  var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
  var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
  var pwdsft = document.getElementById("passwordSafetyLevel1");
  
  {
  if (strongRegex.test(pwd1.value)){pwdsft.innerHTML = '&lt;span style="color:green;"&gt;Safe&lt;/span&gt;'} else if (mediumRegex.test(pwd1.value)) 
  
  {pwdsft.innerHTML = '&lt;span style="color:orange;"&gt;Quite Safe&lt;/span&gt;'} else {pwdsft.innerHTML = '&lt;span style="color:red;"&gt;Unsafe&lt;/span&gt;'};
  }
  };
  
  function passSafetyAppear1()
  
  {$("#passwordSafety1").show()};
  
  function showPassSafety1()
  
  {
  password1Security();
  passSafetyAppear1();
  };
  
  &lt;/script&gt;
  
  &lt;input name="password1" id="password1" type="password" size="15" maxlength="20" style="width:500px; height:30px;" 
  
  onKeyUp="showPassSafety1()"/&gt;
  &lt;br/&gt;
  
  &lt;span name="passwordSafety1" id="passwordSafety1" style="font-size:12pt; display:none;"&gt;Your password is &lt;b 
  
  name="passwordSafetyLevel1" id="passwordSafetyLevel1"&gt;&lt;/b&gt;.&lt;/span&gt;&lt;br/&gt;
  </code></pre>
  
  <p>Thank you in advance,</p>
  
  <p>Pierre</p>