|
|
4#

楼主 |
发表于 2007-10-5 16:11:45
|
只看该作者

check()函数具体检查用户提交的信息(继)
<script language="JavaScript">
function checkid(iden,year,month,day){
if (iden.value.length==15) {
if ((iden.value.lastIndexOf(month.value+day.value))==8) {
return true;
}
return false;
}
if (iden.value.length==18) {
if ((iden.value.indexOf(year.value+month.value+day.value))==6) {
return true;
}
return false;
}
return false;
}
function isCharsInBag (s, bag)
{
var i;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (bag.indexOf(c) == -1) return false;
}
return true;
}
function isEmpty(s)
{
return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{
var whitespace = " \t\n\r";
var i;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (whitespace.indexOf(c) >= 0)
{
return true;
}
}
return false;
}
function isEmail (s,t)
{
if (isEmpty(s))
{
window.alert("输入的E-mail地址不能为空,请输入!");
mobj = eval(t);
mobj.focus();
mobj.select();
return false
}
if (isWhitespace(s))
{
window.alert("输入的E-mail地址中不能包含空格符,请重新输入!");
mobj = eval(t)
mobj.focus()
mobj.select()
return false;
}
var i = 1;
var len = s.length;
if (len > 50)
{
window.alert("email地址长度不能超过50位!");
mobj = eval(t)
mobj.focus()
mobj.select()
return false;
}
pos1 = s.indexOf("@");
pos2 = s.indexOf(".");
pos3 = s.lastIndexOf("@");
pos4 = s.lastIndexOf(".");
if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))
{
window.alert("请输入有效的E-mail地址!");
mobj = eval(t)
mobj.focus()
mobj.select()
return false;
}
else
{
if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1)
|| ( pos1 != pos3 )
|| ( pos4 < pos3 ) )
{
window.alert("请输入有效的E-mail地址!");
mobj = eval(t)
mobj.focus()
mobj.select()
return false;
}
}
if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@"))
{
window.alert("email地址中只能包含字符ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@\n" + "请重新输入" );
mobj = eval(t)
mobj.focus()
return false;
}
return true;
}
function isnumber(str){
var digits="1234567890";
var i=0;
var strlen=str.length;
while((i<strlen)){
var char=str.charAt(i);
if(digits.indexOf(char)==-1)return false;i++;
}
return true;
}
function isnumbercode(str){
var digits="1234567890-/";
var i=0;
var strlen=str.length;
while((i<strlen)){
var char=str.charAt(i);
if(digits.indexOf(char)==-1)return false;i++;
}
return true;
}
</script>
<script language=javascript>
function checkForm(theform){
if (frm.job360.value==0) {
alert("人才类型不能为空。");
frm.job360.focus();
return false;
}
if (document.frm.username.value.length==0){
alert("用户名不能为空。");
mobj = eval("document.frm.username");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.username.value.length<6){
alert("用户名至少为六个字符。");
mobj = eval("document.frm.username");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.password.value.length==0){
alert("密码不能为空");
mobj = eval("document.frm.password");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.password.value.length<6){
alert("密码至少为六个字符。");
mobj = eval("document.frm.password");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.password.value!=document.frm.repassword.value){
alert("密码与确认密码不一致");
mobj = eval("document.frm.repassword");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.name.value.length==0){
alert("真实姓名不能为空");
mobj = eval("document.frm.name");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.idcode.value.length==0){
alert("身份证号码不能为空");
mobj = eval("document.frm.idcode");
mobj.focus()
mobj.select()
return false;
}
if (!isnumber(document.frm.idcode.value)){
alert("身份证号码只能为数字");
mobj = eval("document.frm.idcode");
mobj.focus()
mobj.select()
return false;
}
if (!(document.frm.idcode.value.length==15||document.frm.idcode.value.length==18)) {
window.alert ("您的身份证号码必须为15位或18位 !")
mobj = eval("document.frm.idcode");
mobj.focus()
mobj.select()
return false
}
if (!checkid(document.frm.idcode,document.frm.year,document.frm.month,document.frm.day)) {
alert("身份证号码与出生年月不能对应,请填写正确身份证号码!");
mobj = eval("document.frm.idcode");
mobj.focus()
mobj.select()
return false
}
if (document.frm.education_content.value.length==0){
alert("教育与培训背景不能为空");
mobj = eval("document.frm.education_content");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.workcompanynumber.value.length==0){
alert("任职公司数不能为空");
mobj = eval("document.frm.workcompanynumber");
mobj.focus()
mobj.select()
return false;
}
if (!isnumber(document.frm.workcompanynumber.value)){
alert("任职公司只能为数字");
mobj = eval("document.frm.workcompanynumber");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.job_experience.value.length==0){
alert("工作经历业绩不能为空");
mobj = eval("document.frm.job_experience");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.remark.value.length==0){
alert("自评报告不能为空");
mobj = eval("document.frm.remark");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.jobaddress.value.length==0){
alert("现工作地点不能为空");
mobj = eval("document.frm.jobaddress");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.objective.value.length==0){
alert("求职意向不能为空");
mobj = eval("document.frm.objective");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.JobCat.value==0) {
alert("请选择您要招聘的岗位类别。");
document.frm.JobCat.focus();
return false;
}
if (document.frm.deal.value.length==0){
alert("待遇及其它要求不能为空");
mobj = eval("document.frm.deal");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.tel.value.length==0&&document.frm.mobile.value.length==0)
{
window.alert ("联系电话和手机必填一项!")
mobj = eval("document.frm.tel");
mobj.focus()
mobj.select()
return false
}
if (document.frm.tel.value.length>0)
{
if (!isnumbercode(document.frm.tel.value)){
alert("联系电话只能为数字和-");
mobj = eval("document.frm.tel");
mobj.focus()
mobj.select()
return false;
}
}
if (document.frm.mobile.value.length>0){
if (!isnumber(document.frm.mobile.value)){
alert("手机号只能为数字");
mobj = eval("document.frm.mobile");
mobj.focus()
mobj.select()
return false;
}
}
if (document.frm.email.value=='') {
window.alert ("请输入您的E-mail地址 !")
mobj = eval("document.frm.email");
mobj.focus()
mobj.select()
return false
}
if ( !isEmail(document.frm.email.value,document.frm.email) )
return false
if (document.frm.address.value.length==0){
alert("通信地址不能为空");
mobj = eval("document.frm.address");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.address.value.length<10){
alert("通信地址至少为10个字符");
mobj = eval("document.frm.address");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.post_code.value.length==0){
alert("邮政编码不能为空");
mobj = eval("document.frm.post_code");
mobj.focus()
mobj.select()
return false;
}
if (!isnumber(document.frm.post_code.value)){
alert("邮政编码只能为数字");
mobj = eval("document.frm.post_code");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.post_code.value.length!=6){
alert("邮政编码只能为六位");
mobj = eval("document.frm.post_code");
mobj.focus()
mobj.select()
return false;
}
}
</script> |
|