<script type = "text/javascript" language = "javascript"> function clear1() { if(confirm("確定要清空數據嗎?")) { document.main.text1.value = ""; } } </script> <body> <form name="main"> <input type="text" name="text1" /> <input type="button" name="Submit" value="清空數據" onClick="return clear1();"> </form> </body>