Get the value of a textbox using javascript

Get the value of a textbox using javascript sample code:

<!DOCTYPE html>
<html>
<head>
<script>
// access the value of the above textbox
 var name = document.getElementById('txtFriendName').value;
 alert(name);

</script>
<head>

<body>
Friend name: <input type="text" id="txtFriendName" name="FirstName" value="Dhruv Sheth">

</body>
</html>

 

Leave a Reply