表单递交合法性检测-只允许填写字母  
发布时间:2006-10-14 2:57:44   收集提供:gaoqian
<script language="javascript">
<!--
function CheckForm()
{
if (document.form.yourname.value == "" )
{
alert ("请输入姓名!");
return false;
}

var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for (i=0; i < document.form.yourname.value.length; i++)
{
var CheckChar = document.form.yourname.value.charAt(i);
CheckChar = CheckChar.toUpperCase();
if (Letters.indexOf(CheckChar) == -1)
{
alert ("请输入英文姓名!");
return false;
}
}

}
// -->
</Script>

<form action="" name="form" method="post" onSubmit="return CheckForm()">
<div align="center">
<input type="text" name="yourname">
<input type="submit" name="submit" value="submit">
</div>
</form>  

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50