JS代码判断集锦(之一) ~~~~~~~~~~~~~~~~~~

<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 (document.frm.companyname.value.length==0){ 
alert("单位名称不能为空。"); 
mobj = eval("document.frm.companyname"); 
mobj.focus() 
mobj.select() 
return false; 
}

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; 
}

if (document.frm.positionname.value.length==0){ 
alert("职位名称不能为空"); 
mobj = eval("document.frm.positionname"); 
mobj.focus()

mobj.select()

return false;

}

  出处至:http://xiaobingandxiaoer.iteye.com/blog/1917696

js 技巧 (七)JS代码判断集锦(之一)的更多相关文章

  1. js 技巧 (八)JS代码判断集锦(之二)

    JS代码判断集锦(之二) <INPUT TYPE="button" value="登录"  tabindex="4"> < ...

  2. 常用JS技巧[转]

    作者:72妃 事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture(); even ...

  3. JS代码判断IE6,IE7,IE8,IE9!

    JS代码判断IE6,IE7,IE8,IE9!2011年12月15日 星期四 14:01做网页有时候会用到JS检测IE的版本,下面是检测Microsoft Internet Explorer版本的三种代 ...

  4. 200多个js技巧代码

    1.文本框焦点问题 onBlur:当失去输入焦点后产生该事件 onFocus:当输入获得焦点后,产生该文件 Onchange:当文字值改变时,产生该事件 Onselect:当文字加亮后,产生该文件 & ...

  5. JS代码判断IE6,IE7,IE8,IE9的函数代码

    JS代码判断浏览器版本,支持IE6,IE7,IE8,IE9!做网页有时候会用到JS检测IE的版本,下面是检测Microsoft Internet Explorer版本的三种代码 做网页有时候会用到JS ...

  6. JS技巧

    2016-08-09 200多个js技巧代码(Down) word下载 200多个js技巧代码 目录 1.文本框焦点问题... 6 2.网页按钮的特殊颜色... 6 3.鼠标移入移出时颜色变化... ...

  7. 常用的JS页面跳转代码调用大全

    一.常规的JS页面跳转代码 1.在原来的窗体中直接跳转用 <script type="text/javascript"> window.location.href=&q ...

  8. 提升开发幸福感的10条JS技巧

    鱼头总结一些能够提高开发效率的JS技巧,这些技巧很实用,觉得挺好,想推荐给大家,所以有了这篇文章. 生成随机UID const genUid = () => {  var length = 20 ...

  9. [JS]以下是JS省市联动菜单代码

    以下是JS省市联动菜单代码: 代码一: <html> <head> <title></title> <script language=" ...

随机推荐

  1. Ubuntu10.04安装与配置nfs服务器(转载)

    转自:http://blog.chinaunix.net/uid-25885064-id-3177969.html 1.安装nfs服务   $ sudo apt-get install nfs-ker ...

  2. Linux 常用命令十一 ps

    一.ps命令 Linux中的ps命令是Process Status的缩写. ps命令用来列出系统中当前运行的那些进程.ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻的那些进程,如果想要 ...

  3. (8)css表格

    用css设置表格样式 *<table></table> 标签定义 HTML 表格. * tr 元素定义表格的行:th 元素定义表格的表头:td 元素定义表格中的单元格:capt ...

  4. AOP日志框架实现

    AOP日志框架实现 JDK动态代理实现日志框架 首先,在项目包com.ay.test 下创建业务接口类BusinessClassService,具体代码如下: BusinessC lassServic ...

  5. apicloud运行机制

    1 首先在官网apicloud中,创建项目生成config.xml文件,预设风格. 2 将config.xml文件放在项目跟目录中,Vue项目,必须先打包生产dist文件, 3 本地或者云编译(官方工 ...

  6. Tree CodeForces -932D

    错误记录:如下注释语句 #include<cstdio> #include<algorithm> using namespace std; typedef long long ...

  7. C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]

    原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...

  8. poj2661Factstone Benchmark

    链接 利用log函数来求解 n!<=2^k k会达到400+W 暴力就不要想了,不过可以利用log函数来做 log2(n!) = log2(1)+log2(2)+..log2(n)<=k ...

  9. Java 线程 —— Wait (等待)和 Notify(唤醒)

    Wait (等待)和 Notify(唤醒) 这里讲了一个Wait (等待)和 Notfity(唤醒),下面这个实例(工厂,商店,消费者) 额,然后,你就知道了,需要写三个类:工厂类,Shop类,消费者 ...

  10. CentOS 7 下用 firewall-cmd / iptables 实现 NAT 转发供内网服务器联网

    自从用 HAProxy 对服务器做了负载均衡以后,感觉后端服务器真的没必要再配置并占用公网IP资源. 而且由于托管服务器的公网 IP 资源是固定的,想上 Keepalived 的话,需要挤出来 3 个 ...