惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
Security Latest
Security Latest
P
Privacy International News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
S
Secure Thoughts
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
V
V2EX
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tenable Blog
T
Threat Research - Cisco Blogs
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
Lohrmann on Cybersecurity
F
Full Disclosure
H
Help Net Security
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
A
Arctic Wolf
O
OpenAI News
S
Securelist

博客园 - tf.li

清理MVC4 Internaet 项目模板清理 SQL2014 尝试读取或写入受保护的内存。这通常指示其他内存已损坏 nodejs 环境配置技巧 mongdb window 服务安装批处理 bower 安装后 jade 引用404问题 转自CnBeta 令人深思 [译稿]为什么我们不要 .NET 程序员 JSON.NET、WebService与JQuery协同工作 我修改的IP地址掩码 呵呵~~开心 Ext.Ajax.request 传值问题 从小做大之一---------一切从建模开始 [求助]关于文本行转列的疑问~~ To Terrylee 我的设计模型之小议工厂模式 我的设计模型之装饰者模式 我对线程池的一点理解 面向接口编程之惑 第二版 面向接口编程之惑 我的设计模型之适配器模式 我的设计模型之简单工厂
我的Prototype模式框架
tf.li · 2012-01-05 · via 博客园 - tf.li

最近看了大叔关于JavaScript的手记 感觉不错,自己开发一个利用原型模式的JavaScript库雏形,求各位指教

//作者:李腾飞
//
开发时间:2012-1-5
//
JScript脚本库
//
Email
var Email = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
//手机号码
var mobile = /^((13[0-9]{1})|159|153|18[0-9]{1})+\d{8}$/;
//固定电话(不包含分机)
var Phone = /\d{7|8}$/;
var _instance = null;
var Instance = function() {
if (_instance == null)
_instance = new Tomosoft();
return _instance;
};

var Tomosoft = function() {

};

Tomosoft.prototype.checkEmail = function(text, returnMsg) {
//debugger;
if (Instance().checkNull(text, returnMsg)) {
if (!Email.test(text)) {
alert(returnMsg);
return false;
}
} else {
return false;
}
return true;
};

Tomosoft.prototype.checkMobile = function(text, returnMsg) {
if (Instance().checkNull(text, returnMsg)) {
if (!mobile.test(text)) {
alert(returnMsg);
return false;
}
} else {
return false;
}
return true;
};

Tomosoft.prototype.checkNull = function(text, returnMsg) {
if (text.length <= 0) {
alert(returnMsg);
return false;
}
return true;
};

Tomosoft.prototype.checkPhone = function(text, returnMsg) {
if (checkNull(text, returnMsg)) {
if (!Phone.test(text)) {
alert(returnMsg);
return false;
}
} else {
return false;
}
return true;
};

Tomosoft.prototype.checkLength = function(text, minLength, maxLength, returnMsg) {
if (text.length > minLength && text.length <= maxLength)
return true;
else {
alert(returnMsg);
return false;
}
};

前台调用

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JScript._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<script type="text/javascript" src="jquery-1.6.4.min.js"></script>

<script type="text/javascript" src="Tomosoft.JScriptFreamwork.js"></script>

<script type="text/javascript">
var Tomo = new Tomosoft();
function check() {
if (!Tomo.checkNull($("#Text1").val(), "姓名不能为空!") || !Tomo.checkLength($("#Text1").val(), 0, 10, "长度超出限制!")) {
return false;
}
if (!Tomo.checkEmail($("#Text2").val(), "请输入正确的Email地址!")) {
return false;
}
return true;
}
</script>

</head>

<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Text3" type="text" />
<asp:Button ID="Button1" runat="server" OnClientClick="return check();"
Text
="确 认" onclick="Button1_Click" />
</div>
</form>
</body>
</html>