That is poor, and old, code, but it also has dots . which are not quite visible on the page, and aren't required. JS statements are semi-colon terminated as well;
Code:
function emailcheck(){
var string1 = document.example.email.value;
if (string1.indexOf("@") == -1) {
alert("Please input a valid email address!");
document.example.email.focus();
}
}
It is modern practice NOT to give a form a name, but to use an id. And forms are required to have an action attribute (and should have a method attribute as well).
Anyway, the following will at least get the example working:
Code:
<script>
function emailcheck(){
var string1 = document.example.email.value;
if (string1.indexOf("@") == -1) {
alert("Please input a valid email address!");
document.example.email.focus();
}
}
</script>
<form action="#" method="get" name="example">
<input type="text" size="20" name="email" onblur="emailcheck()">
<strong>Feedback please:</strong>
<textarea name="S1" rows="2" cols="20"></textarea>
<input type="submit" name="B1" value="Submit">
</form>
BTW Your browser' console will have indicated the '.' errors to you.
JavaScript Kit is frequently referred to for examples, but most of the examples I come across are out-dated and/or poor. I recommend
Mozilla! Though, even Mozilla isn't perfect..