一个关于表单验证的简单问题!

小弟我刚开始学网页,在用Macromedia Dreamweaver MX做数据库记录插入时不知道怎么对提交的表单进行验证(总共只有一个页面)。

1<form action="```
2=MM_editAction
3```" method="post" name="form1">   
4...........   
5<input type="submit" value="插入记录"/>   
6...........   
7<input name="MM_insert" type="hidden" value="form1"/>
8</form>

还请大家多指点指点。

---------------------------------------------------------------

你想验证表单的完整性还是验证提交的准确性?
---------------------------------------------------------------

你这表单写不完整,你要验证哪里啊。写清楚一点吧。
---------------------------------------------------------------

1<script>   
2function form1.onsubmit()   
3{if(form1.text.value.substr(0,5)!="http:")   
4{alert("错!")   
5return false   
6}   
7}   
8</script>

---------------------------------------------------------------

 1<script language="JavaScript">   
 2<!--   
 3function String.prototype.Trim() {return this.replace(/(^\s*) ¦(\s*$)/g,"");}   
 4function check(theForm)   
 5{   
 6if (theForm.nick.value.Trim() == "")   
 7{   
 8alert("请输入用户名!");   
 9theForm.nick.focus();   
10return (false);   
11}   
12if (theForm.text.value.substring(0,5) != "http:")   
13{   
14alert("错!");   
15theForm.text.focus();   
16return (false);   
17}   
18}   
19</script>
1<form action="```
2=MM_editAction
3```" method="post" name="form1" onsubmit="return check(this)">
4<input name="nick" type="text"/>
5<input name="text" type="text"/>
6<input type="submit" value="插入记录"/>   
7...........   
8<input name="MM_insert" type="hidden" value="form1"/>
9</form>
Published At
Categories with Web编程
comments powered by Disqus