Posted on 2007-07-11 13:47
angel 阅读(193)
评论(0) 编辑 收藏 所属分类:
javascript
email:/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(obj.ss.value)
整数:!isNaN(obj.ss.value) && !/^\s+$/.test(obj.ss.value)
字母:/^[a-zA-Z-]+$/.test(obj.ss.value)
日期:var test = new Date(v); !isNaN(test)或
var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
if(!regex.test(v)) return false;
var d = new Date(v.replace(regex, '$2/$1/$3'));
return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) &&
(parseInt(RegExp.$1, 10) == d.getDate()) &&
(parseInt(RegExp.$3, 10) == d.getFullYear() )
url: /^(http):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v) (httt或ftp开头的)(http|ftp)
中文:/^[\u4e00-\u9fa5]+$/.test(v)
IP:/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(v)
电话:/^((0[1-9]{3})?(0[12][0-9])?[-])?\d{6,8}$/.test(v)
手机:/(^0?[1][35][0-9]{9}$)/.test(v)