How to reload page after script on Javascript?

Tags: ,



I’m a newbee in javascript and i need to refresh page when script is done:

  <script type="text/javascript">
    function validateForm() {
      var x = document.forms["myForm"]["Hostname"].value;
      if (x == "" || x == null) {
        alert("Name must be filled out");
        return document.location.reload(true);
      }
    }
    </script>

But i don’t understand how to make it work.

Answer

<script type="text/javascript">
function validateForm() {
  var x = document.forms["myForm"]["Hostname"].value;
  if (x == "" || x == null) {
    alert("Please specify a FQDN of your host");
    window.location.reload(true);
    return false;
 </script>

This one works fine. Thanks to all



Source: stackoverflow