這里如果有input type=image 那么直接按這個圖像后會提交表單, 如果有OnSubmit會先執(zhí)行這個函數(shù),感興趣的朋友可以看下這個例子
這里如果有<input type="image"> 那么直接按這個圖像后會提交表單,
如果有OnSubmit會先執(zhí)行這個函數(shù),如果返回false則不提交表單!
代碼如下:
<span style="font-size:14px;"><script language=javascript>
function test()
{
alert("測試!")
}
</script>
<form name="F1" onSubmit="fuck();">
<input type="image" src="" width="51" height="20">
</form></span>
另外一個示例:
代碼如下:
<html>
</head>
<script language="javascript">
function checkEmpty(form){
for(i=0;i<form.length;i++){
alert(form.elements[i].value);
if( form.elements[i].value=="" ){
alert("表單信息不能為空");
return false;
}
}
}
</script>
<body>
<form name="form" method="post" onSubmit="return checkEmpty(form)">
<input name="name" type="text" size="17">
<input name="password" type="password" size="17">
<input type="image" src="" width="51" height="20">
<input type="button" value="AAA" />
</form>
</body>
<html>