表单递交合法性检测-只允许填写字母

网络整理 - 09-09
<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="" method="post" >
<div>
<input type="text">
<input type="submit" value="submit">
</div>
</form>