DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> Javascript實現的自動驗證函數
Javascript實現的自動驗證函數
編輯:關於JavaScript     

test.htm
 1<!-- #include file="message.inc" -->
 2<HTML>
 3<HEAD>
 4<TITLE> New Document </TITLE>
 5    <meta http-equiv="content-type" content="text/html; charset=shift_jis" />
 6    <meta http-equiv="pragma" content="no-cache">
 7    <meta http-equiv="cache-control" content="no-cache">
 8    <meta http-equiv="expires" content="0">
 9<script src="common.js"></script>
10<script src="validate.js"></script>
11
12</HEAD>
13
14<BODY>
15<FORM METHOD=POST ACTION="">
16ID<INPUT TYPE="text" id="txtInt" NAME="txtInt" maxlength="6" feildtype="integer" msg=",<%=IMSG0002%>" ><br>
17ID<INPUT TYPE="text" id="txtInt" NAME="txtInt" maxlength="6" feildtype="integer" msg=",<%=IMSG0002%>" ><br>
18ID<INPUT TYPE="text" id="txtInt" NAME="txtInt" maxlength="6" feildtype="integer" msg=",<%=IMSG0002%>" ><br>
19ID<INPUT TYPE="text" id="txtInt" NAME="txtInt" maxlength="6" feildtype="integer" msg=",<%=IMSG0002%>" ><br>
20
21名稱<INPUT TYPE="text" id="txtString" NAME="txtString" maxlength="5" feildtype="string" msg="<%=IMSG0003%>,<%=IMSG0004%>" mustitem="true"><br>
22名稱<INPUT TYPE="text" id="txtString" NAME="txtString" maxlength="5" feildtype="string" msg="<%=IMSG0003%>,<%=IMSG0004%>" mustitem="true"><br>
23名稱<INPUT TYPE="text" id="txtString" NAME="txtString" maxlength="5" feildtype="string" msg="<%=IMSG0003%>,<%=IMSG0004%>" mustitem="true"><br>
24
25名稱2<INPUT TYPE="text" id="txtStr" NAME="txtStr" maxlength="5" feildtype="string" msg="<%=IMSG0003%>,<%=IMSG0004%>" mustitem="true"><br>
26<INPUT TYPE="button" value="submit" >
27<SCRIPT LANGUAGE="javascript">
28<!--
29//validate()
30//-->
31</SCRIPT>
32</FORM>
33</BODY>
34</HTML>
35
validate.js
 1function validate(){
 2
 3    //var objs = document.all;
 4    //var Elements = document.getElementsByTagName("*");
 5    var Elements;
 6    var ctlArray;
 7    var ctlArrayName;
 8    var i, j;
 9    var elLen, arrLen;
10    var msgs;
11
12    Elements = document.getElementsByTagName("input");
13    arrName ="";
14
15    for ( i in Elements ) {
16    elLen = Elements[i].length;
17
18        if (elLen > 1) {
19        

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved