alert弹出框的问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>调查表</title>
<script type="text/JavaScript">
//import java.util.regex.*;
function isNull(str){
if(str.length==0)
return true;
else
return false;}
//function isN(str){
// if(str==null)
// return true;
// else
// return false;}
// function isChineseChar(String str){
// boolean temp = false;
//// Pattern p=Pattern.compile("[\u4e00-\u9fa5]");
// Matcher m=p.matcher(str);
// if(m.find()){
// temp = false;
// }
// return temp;
// }
function maxMinLength(str){
if(str.length<2)
return true;
else
return false;}
function MLength(str){
if(str.length==10)
return false
else
return true;}
function isEmail(str){
if(str.length==0)
return true;
index1=str.indexOf(".");
index2=str.indexOf("@");
if(index1<1||index2<1||index1-index2<2||index1+1==str.length||index1==null||index2==null)
return true;
else
return false;}
function verifyForm(form){
var username=form.name.value;
var userpass=form.xuehao.value;
var usermail=form.email.value;
var bit=form.bit.value;
var radio=form.RadioGroup1.value;
if(isNull(username)){
alert("请输入用户名!");
form.name.focus();
return false;}
if(maxMinLength(username)){
alert("姓名不得低于2位!");
form.name.focus();
return false;}
//if(isChineseChar(username)){
// alert("姓名为中文!");
// form.name.focus();
// return false;}
if(isNull(userpass)){
alert("请输入学号!");
form.xuehao.focus();
return false;}
if(MLength(userpass)){
alert("学号为10位数");
f.xuehao.focus();
return false;}
if(isEmail(usermail)){
alert("请输入正确的Email!");
form.email.focus();
return false;}
//if(isN(radio)){ //?
//alert("请选择!");
// form.radio.focus();
// return false;}
return true;
}
</script>
<style type="text/css">
.body1 {
background-color: #69F;
}
.body2 {
background-color: #6FF;
}
</style>
</head>
<body>
<h1 align="center">调查问卷</h1>
<form name="form" id="form" action="" method="get" onsubmit="return verifyForm(form)">
<table align="center">
<tr>
<td class="body1">姓名</td>
<td class="body2"><input name="name" type="text" size="14" maxlength="20" /></td>
</tr>
<tr>
<td class="body1">学号</td>
<td class="body2"><input name="xuehao" type="text" size="10" maxlength="10" size="20" /></td>
</tr>
<tr>
<td class="body1">性别:</td>
<td class="body2"><input name="sex" type="radio" value="男" checked="checked" />
男
<input name="性别" type="radio" value="女" />
女</td>
</tr>
<tr>
<td class="body1">邮箱</td>
<td class="body2"><input name="email" type="email" /></td>
</tr>
<tr>
<td class="body1">籍贯</td>
<td class="body2"><select name="select">
<option selected>浙江 </option>
<option >北京 </option>
<option >上海 </option>
<option >安徽 </option>
<option >广东 </option>
</select>
</td>
</tr>
<tr>
<td ><h2 class="body1">单选</h2></td>
</tr>
<tr >
<td class="body1">问题1:</td>
</tr>
<tr>
<td></td>
<td class="body2"><table width="200">
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup1" value="单选" />
单选</label></td>
</tr>
</table></td>
</tr>
<tr>
<td class="body1">问题2:</td>
</tr>
<tr> </tr>
<tr>
<td></td>
<td class="body2"><table width="200">
<tr>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup2" value="单选" />
单选</label></td>
</tr>
</table></td>
</tr>
<tr>
<td class="body1">问题3:</td>
</tr>
<tr> </tr>
<tr>
<td></td>
<td class="body2"><table width="200">
<tr>
<td><label>
<input type="radio" name="RadioGroup3" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup3" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup3" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup3" value="单选" />
单选</label></td>
</tr>
</table></td>
</tr>
<tr>
<td class="body1">问题4:</td>
</tr>
<tr> </tr>
<tr>
<td></td>
<td class="body2"><table width="200">
<tr>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup4" value="单选" />
单选</label></td>
</tr>
</table></td>
</tr>
<tr>
<td class="body1">问题5:</td>
</tr>
<tr> </tr>
<tr>
<td></td>
<td class="body2"><table width="200">
<tr>
<td><label>
<input type="radio" name="RadioGroup5" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup5" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup5" value="单选" />
单选</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="RadioGroup5" value="单选" />
单选</label></td>
</tr>
</table></td>
</tr>
<tr>
<td><h2 class="body1">复选框</h2></td>
</tr>
<tr>
<td class="body1">复选问题 </td>
</tr>
<tr><td></td><Td>
<input name="q1" type="checkbox" value="" checked />value1
<input name="q1" type="checkbox" value="" />value2
<input name="q1" type="checkbox" value="" />value3
<input name="q1" type="checkbox" value="" />value4</td></tr>
<table align="center">
<tr>
<td><input name="submit" type="submit" value="提交" /></td>
<td><input name="reset" type="reset" value="重置" /></td>
</tr>
</table>
</table>
</form>
</body>
</html>
seoris
9 years, 5 months ago