How to make it so that when you enter HTML into a form (<input form, etc.>), the entered value is saved in the Javascript variable

    1 answer 1

    The event is triggered when the field loses focus and its value is changed:

    <input type="text" onchange="var a=this.value; alert('Value is ' + a);"> 

    The event is triggered when the key is pressed:

     <input type="text" onkeypress="var a=this.value; alert('Value is ' + a);" />