Autor:编辑浪子
From:http://bbs.51js.com/thread-68161-1-1.html
//表单验证类
function ValidatorClass()
{
var IsError = false;
//检查姓名,只能输入中文、字母、数字、下划线
this.ChkName = function(obj,msg)
{
if (IsError) return;
if (obj.value.Trim().length<2||(/[^u4e00-u9fa5w]/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查邮件地址
this.ChkEmail = function(obj,msg)
{
if (IsError) return;
if (!/^w+@w+.(?:com|cn|org|net|cc|tv|info|com.cn|net.cn|org.cn|gov.cn)$/i.test(obj.value.Trim())) ErrorHandle(obj,msg);
}
//检查地名,只能是中文,并不能为空
this.ChkPlace = function(obj,msg)
{
if (IsError) return;
if (obj.value.Trim().length<1||(/[^u4e00-u9fa5]/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查详细地址
this.ChkAddress = function (obj,msg)
{
if (IsError) return;
if (obj.value.Trim().length<2) ErrorHandle(obj,msg);
}
//检查邮件编码
this.ChkPostNumber = function (obj,msg)
{
if (IsError) return;
if(!(/^d{6}$/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查手机号码
this.ChkMobile = function (obj,msg)
{
if (IsError) return;
if (!(/^(?:13d|159)-?d{5}(d{3}|*{3})$/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查固定电话号码
this.ChkPhone = function (obj,msg)
{
if (IsError) return;
if (!((/^d{3,4}-?d{4,5}(d{3}|*{3})$/.test(obj.value.Trim())))) ErrorHandle(obj,msg);
}
//提交表单事件
this.Submit = function (Form,msg)
{
if (IsError) return;
if (msg) alert(msg);
Form.submit();
}
//错误处理
function ErrorHandle(obj,msg)
{
alert(msg);
IsError = true;
obj.focus();
}
}
应用实例:
function ChkForm()
{
var Form = document.TestForm;
var Validator = new ValidatorClass();
Validator.ChkName(Form.ZD_UserName,"订货人姓名不合法!");
Validator.ChkEmail(Form.ZD_Email,"订货人邮件地址不合法!");
Validator.ChkPlace(Form.ZD_Province,"订货人省份不合法!");
Validator.ChkPlace(Form.ZD_City,"订货人城市不合法!");
Validator.ChkAddress(Form.ZD_Address,"订货人地址不合法!");
Validator.ChkPostNumber(Form.ZD_Zip,"订货人邮编不合法!");
Validator.ChkMobile(Form.ZD_Mobile,"订货人移动电话不合法!");
Validator.ChkPhone(Form.ZD_Phone,"订货人固定电话不合法!");
Validator.Submit(Form,"验证成功!");
}
From:http://bbs.51js.com/thread-68161-1-1.html
//表单验证类
function ValidatorClass()
{
var IsError = false;
//检查姓名,只能输入中文、字母、数字、下划线
this.ChkName = function(obj,msg)
{
if (IsError) return;
if (obj.value.Trim().length<2||(/[^u4e00-u9fa5w]/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查邮件地址
this.ChkEmail = function(obj,msg)
{
if (IsError) return;
if (!/^w+@w+.(?:com|cn|org|net|cc|tv|info|com.cn|net.cn|org.cn|gov.cn)$/i.test(obj.value.Trim())) ErrorHandle(obj,msg);
}
//检查地名,只能是中文,并不能为空
this.ChkPlace = function(obj,msg)
{
if (IsError) return;
if (obj.value.Trim().length<1||(/[^u4e00-u9fa5]/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查详细地址
this.ChkAddress = function (obj,msg)
{
if (IsError) return;
if (obj.value.Trim().length<2) ErrorHandle(obj,msg);
}
//检查邮件编码
this.ChkPostNumber = function (obj,msg)
{
if (IsError) return;
if(!(/^d{6}$/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查手机号码
this.ChkMobile = function (obj,msg)
{
if (IsError) return;
if (!(/^(?:13d|159)-?d{5}(d{3}|*{3})$/.test(obj.value.Trim()))) ErrorHandle(obj,msg);
}
//检查固定电话号码
this.ChkPhone = function (obj,msg)
{
if (IsError) return;
if (!((/^d{3,4}-?d{4,5}(d{3}|*{3})$/.test(obj.value.Trim())))) ErrorHandle(obj,msg);
}
//提交表单事件
this.Submit = function (Form,msg)
{
if (IsError) return;
if (msg) alert(msg);
Form.submit();
}
//错误处理
function ErrorHandle(obj,msg)
{
alert(msg);
IsError = true;
obj.focus();
}
}
应用实例:
function ChkForm()
{
var Form = document.TestForm;
var Validator = new ValidatorClass();
Validator.ChkName(Form.ZD_UserName,"订货人姓名不合法!");
Validator.ChkEmail(Form.ZD_Email,"订货人邮件地址不合法!");
Validator.ChkPlace(Form.ZD_Province,"订货人省份不合法!");
Validator.ChkPlace(Form.ZD_City,"订货人城市不合法!");
Validator.ChkAddress(Form.ZD_Address,"订货人地址不合法!");
Validator.ChkPostNumber(Form.ZD_Zip,"订货人邮编不合法!");
Validator.ChkMobile(Form.ZD_Mobile,"订货人移动电话不合法!");
Validator.ChkPhone(Form.ZD_Phone,"订货人固定电话不合法!");
Validator.Submit(Form,"验证成功!");
}
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月30日
2024年11月30日
- 黄乙玲1993-受伤的心·冷暖人生[台湾首版][WAV+CUE]
- (G)I-DLE《I SWAY》[FLAC/分轨][150.46MB]
- FTISLAND《Serious》[320K/MP3][82.33MB]
- FTISLAND《Serious》[FLAC/分轨][476.5MB]
- 曾庆瑜1988-你听一听[清优][WAV+CUE]
- Bach,Vieuxtemps,Gruenberg-ViolinConcertos-Heifetz(2012)FLAC
- ConcertoScirocco-SirensSoldiers.SongswithoutWordsfromtheItalianSeicento(2024)[24
- NCT 127《WALK - The 6th Album》[320K/MP3][76.57MB]
- NCT 127《WALK - The 6th Album》[FLAC/分轨][432.81MB]
- Weeekly《Bliss》[320K/MP3][36.2MB]
- TIS《三国志V》原音母盘[24-96][WAV+分轨]
- 林翠萍.1988-绵绵细雨的夜晚【艺歌】【WAV+CUE】
- 张帝《成名经典歌曲》【WAV】
- Weeekly《Bliss》[FLAC/分轨][215.35MB]
- 群星《当打之年》 HQII[WAV+CUE][640M]