0
<html>
<head>
<title>Untitled</title>
</head>
<script>
document.onsubmit = formSubmitted;
function formSubmitted() {
alert("formSubmitted");
}
function clickAction() {
alert("clickAction");
var aForm = document.forms['form2'];
aForm.action = "#";
aForm.submit();
}
</script>
<body>
<form name="form1">
<input type="submit" value="Direct Submit">
</form>
<br>
<form name="form2" action="#$">
<input type="button" value="Onclick Submit" Onclick="clickAction();">
</form>
</body>
</html>
這是我的代碼,我檢測表單提交使用document.onsubmit = formSubmitted; 警報正在工作。如何檢測表單提交,當它通過一個javascript完成
但是當我試圖通過javascript提交表單其無法正常工作(點擊「點擊提交」按鈕)
這不是動態的,那麼爲什麼不使用document.onsubmit = formSubmitted; – udhaya 2012-04-21 09:09:07