<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
function checkname(){
var div = document.getElementById("div1");
div.innerHTML = "";
var name1 = document.form1.text1.value;
if (name1 == "") {
div.innerHTML = "姓名不能为空!";
document.form1.text1.focus();
return false;
}
if (name1.length < 4 || name1.length > 16) {
div.innerHTML = "姓名输入的长度4-16个字符!";
document.form1.text1.select();
return false;
}
var charname1 = name1.toLowerCase();
for (var i = 0; i < name1.length; i++) {
var charname = charname1.charAt(i);
if (!(charname >= 0 && charname <= 9) && (!(charname >= 'a' && charname <= 'z')) && (charname != '_')) {
div.innerHTML = "姓名包含非法字母,只能包含字母,数字,和下划线";
javascript实现简单用户登录表单验证功能
最新推荐文章于 2024-04-07 09:44:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)