<scriptlanguage="JavaScript">
functioncheckid(iden,year,month,day){
if(iden.value.length==15){
if((iden.value.lastIndexOf(month.value+day.value))==8){
returntrue;
}
returnfalse;
}
if(iden.value.length==18){
if((iden.value.indexOf(year.value+month.value+day.value))==6){
returntrue;
}
returnfalse;
}
returnfalse;
}
functionisCharsInBag(s,bag)
{
vari;
for(i=0;i<s.length;i++)
{
varc=s.charAt(i);
if(bag.indexOf(c)==-1)returnfalse;
}
returntrue;
}
functionisEmpty(s)
{
return((s==null)||(s.length==0))
}
functionisWhitespace(s)
{
varwhitespace="tnr";
vari;
for(i=0;i<s.length;i++)
{
varc=s.charAt(i);
if(whitespace.indexOf(c)>=0)
{
returntrue;
}
}
returnfalse;
}
functionisEmail(s,t)
{
if(isEmpty(s))
{
window.alert("输入的E-mail地址不能为空,请输入!");
mobj=eval(t);
mobj.focus();
mobj.select();
returnfalse
}
if(isWhitespace(s))
{
window.alert("输入的E-mail地址中不能包含空格符,请重新输入!");
mobj=eval(t)
mobj.focus()
mobj.select()
returnfalse;
}
vari=1;
varlen=s.length;
if(len>50)
{
window.alert("email地址长度不能超过50位!");
mobj=eval(t)
mobj.focus()
mobj.select()
returnfalse;
}
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()
returnfalse;
}
else
{
if((pos1==pos2-1)||(pos1==pos2+1)
||(pos1!=pos3)
||(pos4<pos3))
{
window.alert("请输入有效的E-mail地址!");
mobj=eval(t)
mobj.focus()
mobj.select()
returnfalse;
}
}
if(!isCharsInBag(s,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@"))
{
window.alert("email地址中只能包含字符ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@n"+"请重新输入");
mobj=eval(t)
mobj.focus()
returnfalse;
}
returntrue;
}
functionisnumber(str){
vardigits="1234567890";
vari=0;
varstrlen=str.length;
while((i<strlen)){
varchar=str.charAt(i);
if(digits.indexOf(char)==-1)returnfalse;i++;
}
returntrue;
}
functionisnumbercode(str){
vardigits="1234567890-/";
vari=0;
varstrlen=str.length;
while((i<strlen)){
varchar=str.charAt(i);
if(digits.indexOf(char)==-1)returnfalse;i++;
}
returntrue;
}
</script>
<scriptlanguage=javascript>
functioncheckForm(theform){
if(document.frm.companyname.value.length==0){
alert("单位名称不能为空。");
mobj=eval("document.frm.companyname");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.address.value.length==0){
alert("单位地址不能为空");
mobj=eval("document.frm.address");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.invest.value.length==0){
alert("投资额不能为空");
mobj=eval("document.frm.invest");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.codeornumber.value.length==0){
alert("法人代码证书号或营业执照编号不能为空");
mobj=eval("document.frm.codeornumber");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.linkman.value.length==0){
alert("联系人不能为空");
mobj=eval("document.frm.linkman");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.linkmanjob.value.length==0){
alert("联系人职位不能为空");
mobj=eval("document.frm.linkmanjob");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.phone.value.length==0){
alert("电话不能为空");
mobj=eval("document.frm.phone");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.email.value==''){
window.alert("请输入您的E-mail地址!")
mobj=eval("document.frm.email");
mobj.focus()
mobj.select()
returnfalse
}
if(!isEmail(document.frm.email.value,document.frm.email))
returnfalse
if(document.frm.introduction.value.length==0){
alert("公司简介不能为空");
mobj=eval("document.frm.introduction");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.positionname.value.length==0){
alert("职位名称不能为空");
mobj=eval("document.frm.positionname");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.jobaddress.value.length==0){
alert("工作地点不能为空");
mobj=eval("document.frm.jobaddress");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.jobfunction.value.length==0){
alert("工作职责不能为空");
mobj=eval("document.frm.jobfunction");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.positionrequre.value.length==0){
alert("职位要求不能为空");
mobj=eval("document.frm.positionrequre");
mobj.focus()
mobj.select()
returnfalse;
}
if(document.frm.salary.value.length==0){
alert("待遇不能为空");
mobj=eval("document.frm.salary");
mobj.focus()
mobj.select()
returnfalse;
}
}
</script>
JS代码判断集锦(之二)
当前1/5页12345下一页阅读全文