|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14357
- 金币
- 2464
- 威望
- 1647
- 贡献
- 1412
|
这个脚本对你可能有帮助:
% L0 E; |7 ^9 o4 E* z<script language="javascript">
9 a. r4 W a: j# ufunction IsDigit(cCheck)
; P+ }. [* A! j4 K! u9 K {
8 r: N4 l3 V2 ^ return (('0'<=cCheck) && (cCheck<='9'));
^: t" `7 [6 |) P& A7 @ }
, i" L/ u+ ^0 l: G# C
x& N6 I4 |% S. i3 I9 Y" G9 vfunction IsAlpha(cCheck)
8 u4 h8 N3 A- [; u5 F { ' Z' C r8 Z" v0 K; z+ @# p
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z'))) " J8 \. ?2 o5 `0 E$ @/ d" \) p; j
}
7 K w1 f4 q9 E- a1 W
# G( L8 F+ i. c2 |# h: ^function IsaNull(cCheck) 5 O) W% B$ R* e4 y4 E2 ]
{ 6 m9 z* Q/ R8 P7 M+ G9 \
return(cCheck != " ") ; ]6 {5 S) F$ C3 U6 R( I9 c
} - M* [+ C9 @ U- `
0 w4 P- j5 I8 \( y* w {1 Wfunction checkform()
/ D/ V9 _. u) K{ ! _3 p5 \% ]' I, W5 x' x2 K' ~
id = document.sform1.id.value;
/ t% _" h* V8 g if (id == "")
! f3 q; ]" n3 S. Y: S5 j {
7 e- v9 p& h2 {( Z alert("请输入注册名");
, h" C& g2 S$ u6 P# O/ Y document.sform1.id.focus(); : b: i$ ^. I, B/ P0 j% o$ `
return false; 1 Y- B! g; S, U- ], s1 I
} 5 J( C) F. ]1 n* j7 F4 N, _
: r' Z9 o. s1 W4 ^. p; q3 z
for (nIndex=0; nIndex<id.length; nIndex++) ' A0 k4 s% V7 e8 W
{
# P% b8 C. k) k0 D. Y Y: Z cCheck = id.charAt(nIndex);
* W6 @& W2 q) r8 @8 `* d- V if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.')) 1 ]3 Z1 E! I1 w2 T" I1 K; A
{
. r& m0 a' I1 x/ \ alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
( g( C, p/ i2 u0 D8 }0 v document.sform1.id.focus();
1 I' h# g0 ^. \' R, l return false; , z7 l, r' o8 i' K+ c, |6 h
}
. a4 P# N! K, N8 z+ t }
: q3 l! |7 F$ V9 v, ?9 S chineseid = document.sform1.chineseid.value; 9 ~0 ?5 c' N( f' u2 }2 T5 _; D! [
if (chineseid == "")
5 d9 X% U) ]9 ^+ `; {! j; a { + n1 `) E/ G8 X4 i' v
alert("请输入中文昵称");
1 C- G# v1 x, T* q document.sform1.chineseid.focus();
S* [( o; t, L0 [ return false; # i7 E; S/ C$ k8 C5 O
} % U- R* P) n+ \% U9 B, q; V
password = document.sform1.password.value; . d4 ]0 Y7 r' A( m- c& O
if (password == "")
9 ~: e6 ?) Q7 P" B: s/ F$ ` { ; {& A2 {$ ~7 U ]
alert("请输入登陆密码");
& w0 H1 x8 _1 i D L1 H; \ document.sform1.password.focus(); , p8 r7 \1 T& j8 ~1 F
return false;
0 U% F# Y! \0 u% z1 ?1 a } 6 N5 }+ a+ a, N9 k t
password1 = document.sform1.password1.value; ! ~ q9 h4 k% x
if (password>password1)
. P' O- F$ L) ^# ^/ T {$ U9 q$ g0 w* t* N/ x0 k0 m) R
alert("重复密码与登陆密码不相同");
0 O# [0 f3 X1 l2 l: X document.sform1.password.focus(); 2 w/ |& [ W" u
document.sform1.password1.focus();
6 S0 @! j5 U! ` { return false;( K5 e) ]0 V' S9 S& ]
} 6 O8 |2 q- O: W, |8 @4 |
if (password<password1) 9 r3 @# Y- Y* k: q: c, q; K
{5 p3 v1 v' E% m4 H
alert("重复密码与登陆密码不相同");
7 u' D/ H6 h$ v; w5 H/ Y% j3 [ document.sform1.password.focus();
5 O3 M( L4 c- X" t& i document.sform1.password1.focus();
# j! [8 m& M- J8 f9 P9 d0 r/ W return false;$ D0 f# f" g; \* ]" `
}
2 H( ]9 t, q1 e: n( g3 L if (document.sform1.email.value == "")
% s Q8 T `; A3 W1 h$ d, I- F { 8 {9 ` r4 ]: s' j
alert("请输入您的E-MAIL地址");
7 p6 K6 `' S% z; B% V document.sform1.email.focus(); 3 |/ f" l2 }8 u0 s! E( w+ `
return false;
- v/ @# b/ r8 w! ~5 p! t } ( U9 i. F1 c7 f2 v8 V; |/ n
4 C7 V0 [9 g7 g, [ email=document.sform1.email.value; # [; g, m) D* |$ m5 E' f
emailerr=0
7 t& K. z+ C' Q/ h/ A for (i=0; i<email.length; i++)
) S) ]: V& A9 o {
# ?# R3 U2 h. L' w( d0 W2 F0 e if ((email.charAt(i) == "@") & (email.length > 5))
6 D7 }3 Z( W+ o8 S- f# j% p { & x# v% A ]& A$ M
emailerr=emailerr+1 ! X% C: _3 e5 O
}
4 b$ Y' \. k9 g* E# i* a5 K1 M }
7 z; X( R9 a: c7 ~% Q if (emailerr != 1)
/ q6 B* x- |# T) W8 p6 X- R8 | p5 z {
3 Y' Y# c5 x& v* W8 b1 h& g- O& ` alert("请输入正确的E-MAIL地址"); # \% O( {% }; w& B. f: {* ?' O
document.sform1.email.focus();
- E& |4 J* }9 Q" U2 [7 g return false; 6 U$ u% B/ |6 X, ~4 H% w. m( N/ n5 z
}
. G8 r, _* V# q( Q
7 ^9 J$ e* j4 `3 }+ R if (document.sform1.checkask.value=="") / B M7 ]! \3 n0 u
{
9 V6 U0 z# y# l; G* C* H9 k: Y alert("密码提示问题不能为空"); , h8 J" P6 N" {+ \
document.sform1.checkask.focus();
0 W9 ?/ f. r3 G v0 { return false;
# n' u& M( n4 o' \/ [0 E1 ^% ^1 Y0 L: Q } " M. r h0 B( Z+ G' E" s0 y& b: V
if (document.sform1.checkans.value=="")
# d1 r, G+ s2 B+ B" J- v8 h4 I {
" k6 x+ L, `: R alert("您的密码提示问题答案不能为空"); 2 Q% Z; o7 Q) X! S
document.sform1.checkans.focus(); 0 F8 s. l9 w1 _
return false; & e- |" g8 j9 c, x
}9 _# ^- w% Q& w: M* ^0 n }/ L3 s
return true;
. f0 T! |) M7 }' |. `7 N ) t: g! {1 X, g8 V
} , x3 w$ Y8 @* U5 y+ M, J6 N
</script> |
|