Check it:
HTML Code:
<!doctype html>
<html>
<body>
<fieldset>
<legend>Enter a movie's name!</legend>
<form name="Form">
<input name="TypedInField" />
<input type="button" value="Click me!" onclick="myFunction()" /> <label>e.g. The Cable Guy</label>
<br/>
<label id="output"> </label>
</form>
</fieldset>
<script>
var myFunction = function () {
var _output = document.getElementById('output');
if (document.Form.TypedInField.value == '') {
alert('Please enter a movie name!');
document.Form.TypedInField.focus();
} else if (document.Form.TypedInField.value == "The Cable Guy") {
_output.innerHTML = "You just wrote the title of a nice movie!";
} else {
_output.innerHTML = "Is this a good movie? I should watch it!";
}
}
</script>
</body>
</html>
Bookmarks