Alerting from Event

Use var from form to alert

HTML

<form id="say-form" onsubmit="return false;" action="#">
    <input type="text" id="said" /><br />
    <input type="submit" value="Alert Now" />
</form>

JavaScript

// Declare VARIABLES and set them same time
var form  = document.getElementById( 'say-form' );
var input = document.getElementById( 'said' );

// Websites run on EVENTS
// ie: keydown, keyup, submit, etc...


// "input" will now run a function when user releases key
form.onsubmit = function() {
  
  // alert the value of input 
  alert( input.value );
    
    
};