I am brand new with java script. My project will involves using external .js files. I can't get this to work. Both my .html file and my .js file are in the same folder.
Here is the html:
Here is the .js file called Validate.js:
Any advice would be appreciated.
EDIT: I am not sure why there are astricks in there. Should be script and "on click"
Here is the html:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>JavaScript Can Validate Input</h1>
<p>Please input a number between 1 and 10:</p>
<form><input id="numb" type="number"> <button type="button"
*******="myFunction()">Submit</button></form>
<p id="demo"> </p>
******** type="text/javascript" src="Validate.js">
*********>
</body>
</html>
Here is the .js file called Validate.js:
Code:
********>
function myFunction() {
var x, text;
// Get the value of the input field with id="numb"
x = document.getElementById("numb").value;
// If x is Not a Number or less than one or greater than 10
if (isNaN(x) || x < 1 || x > 10) {
text = "Input not valid";
} else {
text = "Input OK";
}
document.getElementById("demo").innerHTML = text;
}
*********>
Any advice would be appreciated.
EDIT: I am not sure why there are astricks in there. Should be script and "on click"