|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14395
- 金币
- 2483
- 威望
- 1647
- 贡献
- 1431
|
这个脚本对你可能有帮助:/ G2 j& X% r6 g
<script language="javascript"> ; c! a& }: C5 w: ]
function IsDigit(cCheck) - r# o+ P! m, n k% s H, a( H/ O2 D# M
{
' K) D" z- ^# s1 r1 z return (('0'<=cCheck) && (cCheck<='9'));
; r* R$ X% O( U I! e+ _ }
|+ Z) C9 _% o7 M! u; ?0 B# e7 c 8 e& R: b# n$ L5 Z1 {1 t8 ~
function IsAlpha(cCheck)
9 F# w! w8 C3 O2 y {
^- `% i% u- [& l return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
/ r" y$ M! \6 R" C } : ]9 r! f4 q6 A. a) I& o
: X# E: M* T0 o, R& hfunction IsaNull(cCheck)
) a: X9 b$ _' l. [$ a: T! P {
" X/ h* L1 `! w, j m return(cCheck != " ")
" r5 E& C p+ b3 K, L } 1 J+ I* G/ P! G& Y$ @
4 ~. b# }( c1 Jfunction checkform()
. }: w6 e; L& z. v9 y* i{
! A, C j3 Y* x9 L id = document.sform1.id.value; ! C0 y6 H. K/ a }3 R6 N2 @% K
if (id == "")
2 r0 _' T" i2 A {
6 o, _2 u6 G/ d- b( @ alert("请输入注册名"); ! h1 w# ^) a h0 v* P: t
document.sform1.id.focus(); % D# i# y& z" N$ [* n e
return false; ' ~# C* z5 v7 o, K/ ~# [" o4 X3 I. m
}
7 [& V0 ?" t7 G3 z/ F7 Q+ ]% i - w7 }. N) F: j( n6 H
for (nIndex=0; nIndex<id.length; nIndex++) , t2 e6 @$ _, t1 S+ F
{
6 z- H9 B$ l9 F- D) D cCheck = id.charAt(nIndex); 5 H: M+ h4 H# B e% A4 B
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.')) + [. c; D n0 i! t% _" c7 V
{
, m% p! I, Z; r. _ alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
4 t8 U* W! Y+ t! z6 [ document.sform1.id.focus(); 3 J3 ~2 O9 a, V! \9 \3 O
return false; # I0 M- h8 w: B: n5 z: m- N
}
% _8 y9 R0 h& U. j f7 a } % N6 e' `/ U0 A+ j7 i' h
chineseid = document.sform1.chineseid.value;
) x. k6 k, B/ t6 p3 w' y$ u if (chineseid == "")
+ D" g7 O: K8 N' a1 a* r { % D) k% _! ` [/ M; B
alert("请输入中文昵称"); " ] s( Y5 P3 X
document.sform1.chineseid.focus();
! i' N$ {+ y% |, g) _% E. Z return false;
( N+ o0 A9 w/ n0 R }
+ |, M) A( Z- _$ C password = document.sform1.password.value;
6 O6 U% o- U. Y: _! F if (password == "") : c/ R" B9 ]; f8 L
{
: C K& j8 T+ A7 \& M7 Y) D alert("请输入登陆密码");
& I' _, ]8 u( x4 u+ [5 b( t document.sform1.password.focus();
" p8 `$ K( r" D return false;
' `" n0 j. p% a" k1 y5 \" ` }
4 F) `2 |$ e4 R password1 = document.sform1.password1.value;
! C7 s0 S4 _, C/ ^! U) Q if (password>password1) * z9 s% ], J/ ^$ e! v
{
6 b; x$ ^5 [! F p+ `* L alert("重复密码与登陆密码不相同");
7 ^/ y. j: Y3 t3 F" w9 Q document.sform1.password.focus(); 7 K1 a! w7 {3 D
document.sform1.password1.focus(); 5 y/ G' ]8 P9 Q$ z; U+ i
return false;1 y2 w9 J2 W! [7 N4 W
} . p% T7 e6 }+ f! v( ?/ L2 E
if (password<password1) * [( K- @3 k# h: U% L
{
K/ ^$ g$ ^ i, ~* y alert("重复密码与登陆密码不相同"); / ^, m& t3 M8 a* V
document.sform1.password.focus(); " ~$ O: t" S" f6 Q. C
document.sform1.password1.focus();
- n/ M- w4 H r; D9 G, S5 g5 Y return false;! ?. X/ l, Y* F1 N5 K3 p3 U4 r
} 8 f! M* o O, \
if (document.sform1.email.value == "") / m2 ^( y9 D) f1 F2 j9 B' c
{ + q8 J3 ?! K6 f0 @' H" F/ g/ n p
alert("请输入您的E-MAIL地址"); 4 G: L! [$ I @2 ~
document.sform1.email.focus(); ! q; E, J' g. ]
return false;
1 t: ]% B1 m' p) R$ ~ }
' v( }& w5 J" o- t1 } , j' p& H, }9 E& j: x. B q- H
email=document.sform1.email.value;
. ?% B. c1 N0 j" g emailerr=0
. P" E2 Z1 W+ C9 U3 Y7 ^ for (i=0; i<email.length; i++) # F5 E: l0 |+ Z. ]9 \, c; [/ |0 o# A
{
: t- @' j1 v% Q! a if ((email.charAt(i) == "@") & (email.length > 5))
9 o+ _7 U5 H- u3 j { 1 a+ Z: F, I( h! ^ W8 `4 F
emailerr=emailerr+1 " Y) Q# f* g& L. V
}
* V9 s; ]% k( ^# W/ k m& a, Z }
) _1 A; r6 R; c; J* } if (emailerr != 1) ! Q8 t/ j$ V. @" {0 z
{ : K2 Z8 l- Z" j+ [! g* x
alert("请输入正确的E-MAIL地址"); 0 r G6 S4 m( ], \% h0 H* b
document.sform1.email.focus(); , Q1 k1 K" S3 V& s# v+ D9 u% I
return false;
2 s9 t6 v% G% ~ } & f. w n, e2 W, V0 h
2 J, S7 [! `1 R+ q! t) } if (document.sform1.checkask.value=="") / z* r# [4 n) O& Y
{
* Q7 A4 Z4 x& ^4 r' B alert("密码提示问题不能为空"); 2 z+ J! `1 b) P) B
document.sform1.checkask.focus();
8 b+ d! D+ n; M# Q0 Z' u' [ return false; # Q3 C! L7 Z5 ]: l- ?& O3 p4 c" F: w
} 4 A( ?4 c; C5 I( O/ l
if (document.sform1.checkans.value=="")
: i+ k) x9 k7 Y' w. a. V# B {
! ^7 j# ] R% O3 T# [# h alert("您的密码提示问题答案不能为空");
: X& j- E% e1 u2 ]- f+ @0 Z document.sform1.checkans.focus();
8 V) v \ v! W( s$ S9 e return false; 8 A7 ]3 S3 K+ g+ G' A
}
% s9 x! e+ `( y3 n return true; ( `6 h/ z- b) e
3 P- c5 Z8 {2 I
}
5 N# Y5 \3 G9 V- \! Q</script> |
|