Saturday 26 March 2016

Write a JavaScript program to alert content of text box?

Code:


<!DOCTYPE html>
<html>
<body>
<center><h1>Alert the text</h1>
<form name="form1">
Enter anything:
<input type="text" name="contents">
<input type="button" onclick="myFunction()" value="Try it">   
</form>
<script>
    function myFunction ()
    {
        alert(document.form1.contents.value);
    }
</script>
</center>
</body>
</html>


Output:


No comments:

Post a Comment