Clear TextBox after alert Ok Click in JavaScript

Last Reply 2 months ago By pandeyism

Posted 2 months ago

Dear Sir,

How will clear a textbox alert ok using JavaScript. When user insert some datas after pop up a alert Ok. when user click ok the text box clear

You are viewing reply posted by: pandeyism 2 months ago.
Posted 2 months ago

Hi rajeesh,

Refer below sample.

HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function Save() {
            alert(document.getElementById('txtName').value);
            document.getElementById('txtName').value = "";
        }
    </script>
</head>
<body>
    <div>
        <input type="text" id="txtName" />
        <br />
        <input type="button" value="Submit" onclick="Save();" />
    </div>
</body>
</html>

Demo