JavaScript AlertBox with Function Example

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <title>JavaScript Alert Box</title>
  <script type="text/javascript">
      function displayMessage(message) {
        alert("Your entered text: " + message)
      }
  </script>
</head>
<body>
    <form>
    Enter Text:
    <input type="input" name="message"/>
    <input type="button" onclick="displayMessage(form.message.value)" value="Open Alert Message" />
  </form>
</body>
</html>

Run it...   »

Example Result