How to use alert and display textbox value by javascript

How to use alert message box and display textbox value by java script:



In this post we test a JavaScript code for validating textbox. We know that JavaScript use for validation on client site. Here we take an alert message box which displays whatever is typed in textbox on web page.

Code of JavaScript:

function MsgBox (textstring)
{
alert (textstring)
}

Here textstring is the value of textbox ,we show textbox value in alert message on pege.

Example of JavaScript code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <script language="JavaScript">
function MsgBox (textstring) {
alert (textstring) }


    </script>
    <style type="text/css">
        .style1
        {
            font-sizelarge;
            text-decorationunderline;
        }
    </style>
</head>
<body>
    <form>
<div align="center">
<br />





    <strong><span class="style1">Check entered text by javascript</span></strong><br />
    <br />
    <input name="text1" type="Text" value="hello">
    <input name="submit" type="Button" value="Show Me" onclick="MsgBox(form.text1.value)">
    </form></div>
</body>
</html>
 
use alert and display textbox value by javascript
display textbox value by javascript
Other Asp.net Related post:        



Comments