I would like to check if the user enters a string and verifying it whether the entered string is right or wrong.
Here I have done so far by using JavaScript by using prompt().
I am successful in displaying the prompt message and when I enter any name, it doesn't show anything. I am unable to get the required output.
function myFunction() {
var myText = prompt("Hello World");
var response;
if (myText.search(charIn) > 0) {
response = "Yes, that letter is in the string";
} else {
response = "No good, that letter is NOT in the string";
}
document.getElementById("demo").innerHTML = response;
}
<p>Click the button to demonstrate the prompt box.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>