Display Prompt box using JavaScript

Prompt box in JavaScript allows user to input in a textbox. Here we will see how we can show a prompt box using JavaScript.

<!DOCTYPE html>
<p>Display Prompted box using JavaScript</p>
<button onclick="showPromptBox()">Click here to see prompt box</button>
<p id="pId"></p>
function showPromptBox() {
var text;
var username = prompt("Please enter your username", "");
if (username == null || username == "") {
text = "User cancelled the prompt.";
} else {
text = "Hello !" + username + "Welcome to your SharePoint site";
document.getElementById("pId").innerHTML =text;

One thought on “Display Prompt box using JavaScript

  • December 24, 2021 at 9:58 am

    Great work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher! Come on over and visit my site . Thanks =)


Leave a Reply

Your email address will not be published. Required fields are marked *