<tr><td align = "center">性别:</td><td><input type = "radio" checked name = "sex"/>男<input type = "radio" name="sex"/>女</td></tr>
<tr><td align = "center">兴趣爱好:</td><td id = "habby"><input type = "checkbox"/>喝酒<input type = "checkbox"/>抽烟<input type = "checkbox"/>烫头</td></tr>
<tr><td align = "center">城市:</td><td><select name = "select1">
<option value = "5" selected>--请选择--</option>
<option value = "0">北京</option>
<option value = "1">上海</option>
<option value = "2">广州</option>
</select></td></tr>
<tr><td colspan = "2">个人简历:</td></tr>
<tr><td colspan = "2"><textarea name="text" rows="4" cols="30"></textarea></td></tr>
<tr><td colspan = "2" align = "center"><input type = "submit" value = "提交" /></td></tr>
</table>
</form>
</body>
<!-- ============================================================== -->
<script language = "javascript" type = "text/javascript">
document.form1.username.onblur = function () {
checkName();
}
document.form1.password.onblur = function () {
checkPassword();
}
document.form1.password1.onblur = function () {
checkPass();
}
function check(event) {
var flag = true;
var flag1 = checkName();
var flag2 = checkPassword();
var flag3 = checkPass();
var flag4 = selectTwo();
var flag5 = checkEducation();
var flag6 = text1();
flag = flag1 && flag2 && flag3 && flag4 && flag5 && flag6;
return flag;
}
//简历
function text1() {
var uPass = document.form1.text.value;
if (uPass == 0) {
tiShi(document.form1.text,"请输入简历");
return false;
}else {
delms(document.form1.text);
return true;
}
}
//验证用户名 规定要以字母开头 由10位以内
function checkName() {
var reg = /^[a-zA-Z][a-zA-Z0-9_]{0,9}$/g;
//获取用户名的内容
var uName = document.form1.username.value;
var uOb = document.form1.username;
if (!reg.test(uName)) { //如果验证不成功的话就提示用户
tiShi(uOb,"请输入以字母开头的用户名6到10位");
return false;
} else { //如果成功的话就删除原来的提示信息span
delms(uOb);
return true;
}
function checkPass() {
if (document.form1.password.value != document.form1.password1.value) {
tiShi(document.form1.password1,"你输入的密码与前面不符");
return false;
} else {
delms(document.form1.password1);
return true;
}
}
//至少要选择1个爱好
function selectTwo () {
var arr1 = document.getElementById("habby");
var arr = arr1.getElementsByTagName("input");
var count = 0;
for (var i = 0;i < arr.length ; i++ ) {
if (arr[i].checked) {
count++;
}
}