﻿function chkBooks()
{   
	var f = document.forms[0];
	if (f.ctl00_ContentPlaceHolder1_title1.value == '')	
	{
		alert('请输入标题');
		f.ctl00_ContentPlaceHolder1_title1.focus();
		return false;
	} 
	if (f.ctl00_ContentPlaceHolder1_title1.value.length > 50 )
	{
		alert('输入的标题过长');
		f.ctl00_ContentPlaceHolder1_title1.focus();
		return false;
	} 
	if(f.ctl00_ContentPlaceHolder1_username.value == '')
	{
		alert('请输入用户名');
		f.ctl00_ContentPlaceHolder1_username.focus();
		return false;
	}
	if(f.ctl00_ContentPlaceHolder1_email1.value == '')
	{
		alert('请输入电邮');
		f.ctl00_ContentPlaceHolder1_email1.focus();
		return false;
	}
	if(f.ctl00_ContentPlaceHolder1_username.value.length < 1 || f.ctl00_ContentPlaceHolder1_username.value.length >20)
	{
		alert('用户名长度在1-20个字符间');
		f.ctl00_ContentPlaceHolder1_username.focus();
		return false;
	}
	
	if (f.ctl00_ContentPlaceHolder1_email1.value.search(/^[^\s@:"'<>,&]{2,}@[^\[\.]+\.[^\[]{2,}$/gi) < 0)
	{
		alert('请正确填写你的邮件地址');
		f.ctl00_ContentPlaceHolder1_email1.focus();
		return false;
	}
	if (f.ctl00_ContentPlaceHolder1_email1.value.length > 45)
	{
		alert('请正确填写你的邮件地址');
		f.ctl00_ContentPlaceHolder1_email1.focus();
		return false;
	}
	if (f.ctl00_ContentPlaceHolder1_sex.value == '')
	{
		alert('请选择你的性别');
		f.ctl00_ContentPlaceHolder1_sex.focus();
		return false;
	}
	if(f.ctl00_ContentPlaceHolder1_body.value == '')
	{
		alert("留言内容不能为空");
		f.ctl00_ContentPlaceHolder1_body.focus();
		return false;
	}
	
	f.submit();	
}
