作者:杨余斌 来自: 加入时间:2007-Mar-27
function Form_Validator(theForm)
{
//姓名
if (theForm.username){
if (theForm.username.value == ""){
alert("请输入用户名!");
theForm.username.focus();
return (false);
}
}
//密碼
if (theForm.passwd){
if (theForm.passwd.value == ""){
alert("请输入密碼!");
theForm.passwd.focus();
return (false);
}
if (theForm.passwd.value == ""){
alert("请输入密碼!");
theForm.passwd.focus();
return (false);
}
if (theForm.passwd.value != theForm.repasswd.value){
alert("密码输入不一致!");
theForm.passwd.focus();
return (false);
}
}
if (theForm.question){
if (theForm.question.value == ""){
alert("请输入取回密码问题!");
theForm.question.focus();
return (false);
}
}
if (theForm.answer){
if (theForm.answer.value == ""){
alert("请输入取回密码答案!");
theForm.answer.focus();
return (false);
}
}
//E-MAIL郵件地址檢測
if (theForm.email){
if (theForm.email.value == ""){
alert("请输入E-MAIL地址!");
theForm.email.focus();
return (false);
}
var re = new RegExp("^([A-Za-z0-9_|-]+@[A-Za-z0-9|-]+
([.][A-Za-z0-9|-]+)*[.][A-Za-z0-9+$","ig");
{if (!re.test(theForm.email.value))
{alert("E-MAIL输入不正确!");
theForm.email.focus();
return false;
}
}
}
}
使用时只需在form提交时加上该程序,onsubmit="return Form_Validator(this)"
[声明]
以上文章如果标明为杨余斌自创,在转载时必须注明出处,并且不得修改文章内容,和文章内的链接等。
以上文章或资料除注明为杨余斌自创或编辑整理外,均为各方收集或网友推荐所得。其中摘录的内容以共享、研究为目的,不存在任何商业考虑。
目前网站上有些文章未注明作者或出处,甚至标注错误,此类情况出现并非不尊重作者及出处网站,而是因为有些资料来源的不规范。如果有了解作者或出处的原作者或网友,请告知,本网站将立即更正注明,并向作者或出处单位道歉。
被摘录的对象如有任何异议,请与本站联系,联系邮箱:webmaster at yangyubin.com,本站确认后将立即撤下。谢谢您的支持与理解