当前位置:编程学习 > asp >>

表单验证

<script language="javascript">
<!--
function bbs(theForm)
{
if (theForm.user.value == "")
{
alert("请输入用户名!");
theForm.user.focus();
return (false);
}
if (checktext(theForm.user.value))
{
alert("请您输入有效用户名!");
theForm.user.select();
theForm.user.focus();
return (false);
}
if (theForm.passwd.value == "")
{
alert("请输入密码!");
theForm.passwd.focus();
return (false);
}
if (checktext(theForm.passwd.value))
{
alert("请您输入有效密码!");
theForm.passwd.select();
theForm.passwd.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = theForm.user.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}

if (!allValid)
{
alert("您输入的用户名不能含有字符 < / > ' ! =等!");
theForm.user.focus();
return (false);
}
if (checktext(theForm.user.value))
{
alert("您输入的用户名不能含有字符 < / > ' ! =等!");
theForm.user.select();
theForm.user.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = theForm.passwd.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
补充:asp教程,客户端相关打印 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,