<form id="form" style="background: green;  width: 200px;">
  <input type="button" onclick="return false;" value="login">
  <div style="display: none; height: 50px;">
    <input id="inp" name="inp" >
  </div>
</form>
<script>
window.onload = function () {
  var form = document.getElementById('form');
  var div = form.children[1];
  var coords, x, y;
  form.onmouseover = function () {
    div.style.display = 'block';
    document.onmousemove = function (e) {
      coords = form.getBoundingClientRect();
      x = e.clientX;
      y = e.clientY;
      if (x > coords.right || y > coords.bottom || x < coords.left || y < coords.top) {
        div.style.display = 'none';
        document.onmousemove = null;
      }
    }
  }
}
</script>