NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.
<!--</script>
function sayHello()// -->
{
var theirname;
theirname=document.myform.username.value;
if (theirname != "")
alert("Hello "+theirname+"!");
else
alert("Don't be shy.");
}
<b>What's your name?</b></form>
<input type="text" name="username" id="username" size="20" />
<input type="button" value="Greet" onclick="sayHello();" />