<html>
<head>
<title>
</title>
<script LANGUAGE="JavaScript">
function mm(form){
String.prototype.trim = function(){
return this.replace(/(^\s+)|(\s+$)/g, "");
}
var meizz = {}; //for checkbox radio
for(var i=0; i<form.elements.length; i++){
var e = form.elements[i];
switch(e.tagName){
case "SELECT" :
if(!e.disabled && e.value.trim()=="" && e.clientHeight>0){
alert("性别不能为空");
e.focus();
return;
}
break;
case "INPUT" :
if(!e.disabled && e.type!="hidden" && e.clientHeight>0){
if("text,ename,file".indexOf(e.type)>-1 && e.value.trim()==""){
alert("姓名不能为空");
e.focus();
return;
}else if("text,telepphone,file".indexOf(e.type)>-1 && e.value.trim()==""){
alert("电话号码不能为空");
e.focus();
return;
}
}
break;
}
}
}
</SCRIPT>
</head>
<body>
<form name=form1>
姓名:<input name=a type=ename>
电话:<input name=b type=telephone>
性别:<select name="esex">
<option value="2"></option>
<option value="1">男</option>
<option value="0">女</option>
</select>
</form>
<input type=button value=check onclick="mm(document.form1)">
</body>
</html>