互联网观察 网站建设 网站运营 网上创业 电子商务 建站软件 建站软件教程 网站开发 网页制作 收藏本站
建站常识 | 域名 | 主机 | 网上开店 | 搜索引擎优化 | 网站推广 | 网络赚钱 | 站长经验 | 个人建站 | 网站设计 | 网页特效 | wap网站

ULTRADEV:会员注册及登陆系统 八


  
附: 如果您想在Register.asp用户注册时,对用户输入的用户名、电子邮件、密码进行检测,可以通过在$#@60;head$#@62;$#@60;/head$#@62;标签中加入以下的javascript来实现。如果你只需要检验用户名、电子邮件、密码是否已经填入,而不需要检测EMAIL输入的正确性,就只需加入蓝色代码部分。
$#@60;script language="JavaScript"$#@62;
$#@60;!--
function isEmpty(s)
{
return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{
var whitespace = " \t\n\r";
var i;
// Is s empty?
//if (isEmpty(s)) return true;
// Search through string"s characters one by one
// until we find a non-whitespace character.
// When we do, return false; if we don"t, return true.
for (i = 0; i $#@60; s.length; i++)
{
// Check that current character isn"t whitespace.
var c = s.charAt(i);
if (whitespace.indexOf(c) $#@62;= 0)
{
return true;
}
}

// All characters are whitespace.
return false;
}
function isCharsInBag (s, bag)
{
var i;
// Search through string"s characters one by one.
// If character is in bag, append to returnString.
for (i = 0; i $#@60; s.length; i++)
{
// Check that current character isn"t whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) return false;
}
return true;
}
function isEmail (s)
{
// is s Empty?
if (isEmpty(s))
{
window.alert("输入的E-mail地址不能为空,请输入!");
return false;
}
//is s contain whitespace
if (isWhitespace(s))
{
window.alert("输入的E-mail地址中不能包含空格符,请重新输入!");
return false;
}
// there must be $#@62;= 1 character before @, so we
// start looking at character position r> // (i.e. second character)
var i = 1;
var len = s.length;
if (len $#@62; 50)
{
window.alert("email地址长度不能超过50位!");
return false;
}

pos1 = s.indexOf("@");
pos2 = s.indexOf(".");
pos3 = s.lastIndexOf("@");
pos4 = s.lastIndexOf(".");
//check "@" and "." is not first or last character
if ((pos1 $#@60;= 0)||(pos1 == len)||(pos2 $#@60;= 0)||(pos2 == len))
{
window.alert("请输入有效的E-mail地址!");
return false;
}
else
{
//check @. or .@
if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1)
|| ( pos1 != pos3 ) //find two @
|| ( pos4 $#@60; pos3 ) ) //. should behind the "@"
{
window.alert("请输入有效的E-mail地址!");
return false;
}
}
if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@"))
{
window.alert("email地址中只能包含字符ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@\n" + "请重新输入" );
return false;
}
//is s contain invalid characters
/*
var badChar = "$#@62;$#@60;,[]{}?/+=|\\"\":;!#$%^&()`";
if ( isCharsInBag( s, badChar))
{
alert("请不要在email地址中输入字符 " + badChar + "\n" );
alert("请重新输入" );
return false;
}
*/
return true;
}
function checkdata() {
if (document.form1.UserID.value=="") {
window.alert ("请输入您的注册名 !")
return false
}
if (document.form1.UserID.value.length$#@60;4) {
window.alert ("你的注册名需长于3位 !")
return false
}
if (document.form1.Email.value=="") {
window.alert ("请输入您的E-mail地址 !")
return false
}
if ( !isEmail(document.form1.Email.value) )
return false

if (document.form1.Password.value=="") {
window.alert ("请输入您的密码 !")
return false
}
if (document.form1.Password.value.length$#@60;5) {
window.alert ("您的密码数必须大于4位 !")
return false
}
if (document.form1.rePassword.value=="") {
window.alert ("请输入您的重复密码 !")
return false
}
if (document.form1.Password.value!=document.form1.rePassword.value) {
window.alert ("您的密码不一致 !")
return false
}
return true
}
//--$#@62;
$#@60;/script$#@62;
然后,在$#@60;form$#@62;标签中加入onSubmit="return checkdata()"
[结束语] 注:
“流程图部分”是为了使本教程看起来更明了,而加上的内容。
“附录部分”是为了完善“注册页面”而另外加入的一段javascript代码,希望对你有用。
  




上一篇:深入DW插件的奥秘(5)
下一篇:用DW插件制作动态下拉菜单
相关分类
网页制作 (4121)
  html教程 (591)
  css教程 (546)
  Dreamweaver教程 (1006)
  JavaScript教程 (834)
  网页制作技巧 (378)
  网页特效 (766)
 



版权所有 Copyright© 2006 黑马建站宝典 联系方式:heima123#gmail.com