1、数字
01 |
function testisNum(object) |
04 |
var s =document.getElementById(object.id).value; |
2、电话号码,传真
02 |
function isTel(object) |
06 |
var s =document.getElementById(object.id).value; |
07 |
var pattern =/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/; |
13 |
alert( '请输入正确的电话号码:电话号码格式为国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)"' ); |
3、邮箱
01 |
function Check(object) |
03 |
var s =document.getElementById(object.id).value; |
04 |
var pattern =/^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/; |
4、手机号码
02 |
function isMobile(object) |
04 |
var s =document.getElementById(object.id).value; |
05 |
var reg0 = /^13\d{5,9}$/; |
06 |
var reg1 = /^153\d{4,8}$/; |
07 |
var reg2 = /^159\d{4,8}$/; |
08 |
var reg3 = /^0\d{10,11}$/; |
10 |
if (reg0.test(s))my= true ; |
11 |
if (reg1.test(s))my= true ; |
12 |
if (reg2.test(s))my= true ; |
13 |
if (reg3.test(s))my= true ; |
02 |
function isdate(object) |
04 |
var s =document.getElementById(object.id).value; |
05 |
var pattern =/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/; |
5、邮编
02 |
function isPostalCode(object) |
04 |
var s =document.getElementById(object.id).value; |
05 |
var pattern =/^[0-9]{6}$/; |
6、日期
02 |
function isdate(object) |
04 |
var s =document.getElementById(object.id).value; |
05 |
var pattern =/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/; |
posted on 2010-07-21 16:58
asiawang 阅读(209)
评论(0) 编辑 收藏