| 编程开发中常用的javascript正则表达试 |
| 来源:
发布时间:2008-07-17 发布人:
浏览:
人次
字体:
[大
中
小]
|
|
/** * 验证时间 */ function checkTextDataForTIME(strValue) { var regTextTime = /^(\d+):(\d{1,2}):(\d{1,2})$/; return regTextTime.test(strValue); } ----------------------------------------------------------------------------------------------------------- /** * 验证电话号码 */ function checkTextDataForPHONE(strValue) { var regTextPhone = /^(\(\d+\))*(\d)+(-(\d)+)*$/; return regTextPhone.test(strValue); } ----------------------------------------------------------------------------------------------------------- /** * 验证EMail */ function checkTextDataForEMAIL(strValue) { var regTextEmail = /^[\w-]+@[\w-]+(\.(\w)+)*(\.(\w){2,3})$/; return regTextEmail.test(strValue); } ----------------------------------------------------------------------------------------------------------- /** * 验证URL */ function checkTextDataForURL(strValue) { var regTextUrl = /^(file|http|https|ftp|mms|telnet|news|wais|mailto):\/\/(.+)$/; return regTextUrl.test(strValue); } ----------------------------------------------------------------------------------------------------------- /** * 验证邮政编码 */ function checkTextDataForPOST(strValue) { var regTextPost = /^(\d){6}$/; return regTextPost.test(strValue); } ----------------------------------------------------------------------------------------------------------- /** * 验证普通字串,只要字串中不包含特殊字符即可 */ function checkTextDataForNORMAL(strValue) { // 特殊字符验证格式 var regTextChar = /([\*\"\'<>\/])+/ ; return !regTextChar.test(strValue); } ----------------------------------------------------------------------------------------------------------- /** * 验证整数,包含正整数和负整数 */ function checkTextDataForINTEGER(strValue) { var regTextInteger = /^(-|\+)?(\d)*$/; return regTextInteger.test(strValue); }
共2页: 上一页 [1] 2 下一页
| |
| |
|
|
|
|
| §最新评论:(评论内容只代表网友观点,与本站立场无关!) | |
|
|
|
|
| 注意:请勿在本站发布政治话题、色情及违反法律的内容。 |
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。 |