js 技巧 (七)JS代码判断集锦(之一)
2021-07-12 23:06
标签:职位 als ber lan git app job link orm JS代码判断集锦(之一) ~~~~~~~~~~~~~~~~~~
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
{
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
{
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
{
window.alert("请输入有效的E-mail地址!");
mobj = eval(t)
mobj.focus()
mobj.select()
return false;
}
else
{
if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1)
|| ( pos1 != pos3 )
|| ( pos4
{
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
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
var char=str.charAt(i);
if(digits.indexOf(char)==-1)return false;i++;
}
return true;
}
if (document.frm.address.value.length==0){
alert("单位地址不能为空");
mobj = eval("document.frm.address");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.invest.value.length==0){
alert("投资额不能为空");
mobj = eval("document.frm.invest");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.codeornumber.value.length==0){
alert("法人代码证书号或营业执照编号不能为空");
mobj = eval("document.frm.codeornumber");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.linkman.value.length==0){
alert("联系人不能为空");
mobj = eval("document.frm.linkman");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.linkmanjob.value.length==0){
alert("联系人职位不能为空");
mobj = eval("document.frm.linkmanjob");
mobj.focus()
mobj.select()
return false;
}
if (document.frm.phone.value.length==0){
alert("电话不能为空");
mobj = eval("document.frm.phone");
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.introduction.value.length==0){
alert("公司简介不能为空");
mobj = eval("document.frm.introduction");
mobj.focus()
mobj.select()
return false;
}
下一篇:js 技巧 (五)