<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "表單驗證....??"]]></title>
		<link>https://forum.andowson.com/posts/list/5.page</link>
		<description><![CDATA[Latest messages posted in the topic "表單驗證....??"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>表單驗證....??</title>
				<description><![CDATA[ 請教一下,text欄位若沒輸入值即顯示提醒視窗... 
<br>
狀況1:沒輸入值,點圖片,正常 
<br>
狀況2:沒輸入值,按Enter鍵,異常!!(為何提示視窗會彈出兩次?) 
<br>
[code]&lt;%@ page contentType="text/html; charset=UTF-8" %&gt; 
<br>
&lt;html&gt; 
<br>
&lt;head&gt; 
<br>
&lt;/head&gt; 
<br>
&lt;body&gt; 
<br>
&lt;% 
<br>
 String a = null; 
<br>
 a = request.getParameter("keyword"); 
<br>
 out.println(a); 
<br>
%&gt; 
<br>
&lt;script language="javascript"&gt; 
<br>
 function test() { 
<br>
 if( document.formt.keyword.value == "" ) { 
<br>
 alert("請輸入值"); 
<br>
 return false; 
<br>
 } else { 
<br>
 return true; 
<br>
 } 
<br>
 } 
<br>
&lt;/script&gt; 
<br>
&lt;form name="formt" method="POST" action="/member/test.jsp" onsubmit="return test()"&gt; 
<br>
 輸入:&lt;input name="keyword" size="20" value="" type="text" onkeypress="if ( event.keyCode == 13 ) test();"&gt; 
<br>
 &lt;a href="javascript:void(test())"&gt;&lt;img src="/images/searchgame.gif" width="68" height="20" align="absmiddle"&gt;&lt;/a&gt; 
<br>
&lt;/form&gt; 
<br>
&lt;/body&gt; 
<br>
&lt;/html&gt;[/code]]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/276/488.page</guid>
				<link>https://forum.andowson.com/posts/preList/276/488.page</link>
				<pubDate><![CDATA[Fri, 3 Oct 2008 19:08:41]]> GMT</pubDate>
				<author><![CDATA[ viva]]></author>
			</item>
			<item>
				<title>回覆:表單驗證....??</title>
				<description><![CDATA[ 1.onkeypress會再按下Enter時執行一次test()，此外，按下Enter對瀏覽器而言等同於要求submit表單，於是表單被送出 
<br>
2.onsubmit會在表單送出時執行一次test()]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/276/489.page</guid>
				<link>https://forum.andowson.com/posts/preList/276/489.page</link>
				<pubDate><![CDATA[Sat, 4 Oct 2008 11:21:50]]> GMT</pubDate>
				<author><![CDATA[ andowson]]></author>
			</item>
			<item>
				<title>回覆:表單驗證....??</title>
				<description><![CDATA[ [quote=andowson]按下Enter對瀏覽器而言等同於要求submit表單，於是表單被送出[/quote] 
<br>
成功了,上面這句話點醒我.....謝謝指導!! 
<br>
[code] 輸入:&lt;input name="keyword" size="20" value="" type="text" onkeyDown="if( event.keyCode == 13 &amp;&amp; document.formt.keyword.value == '') { alert('請輸入值');return false;} else {return true;}"&gt; [/code]]]></description>
				<guid isPermaLink="true">https://forum.andowson.com/posts/preList/276/490.page</guid>
				<link>https://forum.andowson.com/posts/preList/276/490.page</link>
				<pubDate><![CDATA[Sat, 4 Oct 2008 11:44:50]]> GMT</pubDate>
				<author><![CDATA[ viva]]></author>
			</item>
	</channel>
</rss>