bestlong 怕失憶論壇's Archiver

bestlong 發表於 2010-9-3 13:41

讓表單在送出前顯示對話框再確認一次

[code]<script language="JavaScript">
<!--
function confirmSubmit() {
if (confirm("Really submit this form?")) return true;
else return false;
}
//-->
</script>
<form action="" method="post" onSubmit="return confirmSubmit();">
Your name: <input type="text" name="username">
<input type="submit" name="submit" value="Go!">
</form>[/code]

bestlong 發表於 2010-9-3 13:44

可以再簡化成[code]<form action="" method="post" onSubmit="return confirm('Really submit this form?');">
Your name: <input type="text" name="username">
<input type="submit" name="submit" value="Go!">
</form>[/code]
頁: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.