代码示例:(标识:dhtm_event_onsubmit)
<html>
<head>
<script type="text/javascript">
function confirmInput()
{
fname=document.forms[0].fname.value
alert("您好 " + fname + "!您会被重定向到 www.w3School.com.cn")
}
</script>
</head>

<body>
<form onsubmit="confirmInput()" action="http://www.sou-xun.com/">
请输入您的名字:<input id="fname" type="text" size="20">
<input type="submit">
</form>
</body>

</html>
运行结果: