Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript Check the answer

<form id="form">
    <input id="MyEnter" type="text" name="inputBox" placeholder="Enter your answer"><br> 
</form>

<script>
var myenter = document.getElementById("MyEnter");
myenter.addEventListener("keypress", function(event) {
  if (event.key === "Enter") {
    event.preventDefault();
    var answer = 'Hello'
    var mytext = document.getElementById("MyEnter").value;
    if (mytext==answer) {
        alert('opening another page');
        window.open("https://www.google.com");
    }else{
        alert("Incorrect answer");
    }
  }
});
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript How to show array content in output window 
Javascript :: filter json array based on multiple arguments including lists 
Javascript :: How to get access to the PromiseResult in React when calling Azure Cosmos DB api 
Javascript :: vtk js 
Javascript :: angularjs Indicators and Paginator styling for PrimeNG Carousel 
Javascript :: How to create a table with indents from nested JSON in angularjs 
Javascript :: angularjs how to get a response from a post request 
Javascript :: angularjs How to add row after the last row in ng2 smart table 
Javascript :: Angularjs to Angular Migration: factory prototype 
Javascript :: AngularJS Pagination not showing all pages 
Javascript :: Se Chartjs horizontal 
Javascript :: React Native, <TextInput onChange{(text) = setState(text)} is returning an object instead of a string. Eventhough the default value is a String. Why 
Javascript :: check if Popups and Redirects are allowed 
Javascript :: Target one specific Jquery Data Table theader for CSS styles 
Javascript :: fill array with random numbers javascript using arrow function 
Javascript :: fireOnChange 
Javascript :: remember me option in firebase + react 
Javascript :: saves javascript 
Javascript :: javascript scrolltoview vue 
Javascript :: "Uncaught (in promise) TypeError: dispatch is not a function" 
Javascript :: javascript object access time complexity 
Javascript :: Vue Js The specified value cannot be parsed, or is out of range 
Javascript :: difference between push and pop in javascript 
Javascript :: React Native - iOS Release build crashing 
Javascript :: checkbox null value javascript 
Javascript :: javascript hide div 
Javascript :: errors thrown inside asynchronous functions will act like uncaught errors 
Javascript :: vue append component to div 
Javascript :: Update react final form field 
Javascript :: simple JSX example 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =