|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14343
- 金币
- 2457
- 威望
- 1647
- 贡献
- 1405
|
这个脚本对你可能有帮助:% T2 z1 o9 B% |
<script language="javascript">
/ U/ u7 v. x1 C: C( Ufunction IsDigit(cCheck) / B0 c7 ~& c; m0 H" x. w
{
3 v: T# P7 E& s+ @ return (('0'<=cCheck) && (cCheck<='9')); # q1 t& \' ^) R( Y% [
} 9 h9 z* k" ]3 T$ m3 A+ y
8 I: U' ^9 n8 g( c+ mfunction IsAlpha(cCheck)
1 [) I8 o$ \+ ?9 L* Y9 d, \ { $ x9 z9 C; T6 h
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
3 X/ a6 Z- N2 @; D) d x, J }
4 i- Q1 x3 w% C+ O# H
6 ~0 y* g, a4 E" k% b: ^2 qfunction IsaNull(cCheck)
! e1 u, n& X+ W" S* a {
$ G- i' A1 u3 ]; ` return(cCheck != " ") + j6 J1 {* f5 _
} % I& B- o% \' n
' @8 F; Y; O1 q0 w
function checkform()
1 }3 Z+ U6 {4 X5 j" X; u{ 6 ]0 j( Q" t( u1 r0 a% V; N8 t
id = document.sform1.id.value; ) ~. d0 C, Y7 M
if (id == "")
# Q) E5 n! f. ]6 q# Q* [ {
4 O. \ `7 |. V0 C5 S9 P! n8 b5 T0 g alert("请输入注册名");
7 X; l& u+ Z* y6 J: R document.sform1.id.focus();
: g: k" {6 t2 W" t return false; & t! ?/ ` B2 H5 |3 Y- E
} - n2 V p" J3 @9 q: g9 `0 T
. ?: X. [2 n \1 `
for (nIndex=0; nIndex<id.length; nIndex++)
- v& B$ x8 l Y* w3 c {
) k5 S! ^3 A% W cCheck = id.charAt(nIndex); ; u8 P& S0 d: g0 I3 f+ y6 A4 ?) ]
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
* r. e7 U5 V6 Z/ \7 i8 ~- B4 } {
6 @) C0 r; M8 I alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文"); 9 w, W2 |; N. X2 C9 c9 ^4 X/ Y& Z
document.sform1.id.focus();
$ n/ X! |/ P) i( f return false;
3 ?/ }: g- a' |4 I1 i { }
: w1 X! n$ j1 U: X* `9 t }
( ^2 l+ e: x" f" ~! F) N+ h5 _. F chineseid = document.sform1.chineseid.value;
" n9 W4 I6 n& t3 g if (chineseid == "") 1 e8 e h! b9 Q: \& Q
{ 4 l' Y( D+ W7 ]) }2 c- l, N; o
alert("请输入中文昵称"); # {) A; m3 f5 c6 |) F
document.sform1.chineseid.focus();
G4 C9 j2 X0 Z- s; G return false; " x' B) x% _5 D" k2 ~/ i7 g
} 9 e) a/ i( A1 a1 K; L
password = document.sform1.password.value;
% B8 ]0 I% x) u( S- R if (password == "") $ u: E3 a7 O. @, d3 g5 M% _. Q, y! i
{ 7 x3 \# o7 W, Z
alert("请输入登陆密码");
6 |" T' p4 U f9 t( ?$ Z S: | document.sform1.password.focus(); ! b) z0 N/ G% {8 P3 j3 N& V: V
return false; 2 S: n* m! }; |- K; r" c9 r
}
' p$ y( t2 N0 J9 \( z& p. o4 i password1 = document.sform1.password1.value; ' x6 T& Q. o. _7 _7 ~
if (password>password1)
S+ C. m% f. M: D {
0 E( n7 i: i# u! v9 |. L3 P9 E! O alert("重复密码与登陆密码不相同");
8 r* h$ q: @( @' J* S. i document.sform1.password.focus(); 2 D# k+ l' D8 e; T& N
document.sform1.password1.focus(); & H' E: z" i4 Y6 R, z8 [& y
return false;% V* G; D5 o6 ^' K" s c$ P0 l1 f
}
% V0 _2 m; R7 i( _if (password<password1)
3 y$ |* [* |8 S/ e9 E$ y {+ h! g5 A2 e2 N a( g7 Q. V% t
alert("重复密码与登陆密码不相同");
$ p J J( w% K$ G document.sform1.password.focus(); " ~/ k5 {8 b- i1 k( G7 C; n! G. e# W
document.sform1.password1.focus(); ' y9 G: |; c- }- E, I& v
return false;2 [- F' N+ U7 A4 e& V# c
}
( o' y+ R6 C7 g: U if (document.sform1.email.value == "")
w7 a5 J7 Z2 y( `5 w6 u' u+ s c { 3 P7 r6 j5 j0 a- T9 T9 ~
alert("请输入您的E-MAIL地址");
5 O. @; _7 y. r& P% k+ R document.sform1.email.focus(); ) o/ A# b* g0 x3 s/ D# [
return false; % L& W+ X! ?( q9 a7 j
} . l8 ]. c* N( [1 L6 w' z
& {: E) h5 n h' E% Q email=document.sform1.email.value;
2 V" Q5 m/ V& \ emailerr=0 + g% O. Z* g) I/ w
for (i=0; i<email.length; i++)
- f/ ?2 t9 K9 b. O { 7 }$ X0 M0 {( K; @) w
if ((email.charAt(i) == "@") & (email.length > 5))
& U) d! y8 P: @, `2 R( i { : T3 D4 H8 ]8 J
emailerr=emailerr+1
5 f/ h8 q) h* v( }- j9 V }
! e$ f5 _0 [' _5 v. U }
6 O8 H+ C9 i7 I/ H& V- s+ e9 T if (emailerr != 1) 4 ^0 k8 i) }8 {+ d7 K. b1 {
{ ; w) x1 |; E$ [' b% ^
alert("请输入正确的E-MAIL地址");
/ K$ V4 N0 i3 i; c document.sform1.email.focus(); 9 F" W+ A0 Z! M0 J
return false; 2 d5 N, F7 z$ l5 P/ J
}
8 X4 X; O* r0 B/ ~ z1 k4 c 8 ^ ~3 P6 m! v/ y% _& U
if (document.sform1.checkask.value=="")
8 m# t' R0 d4 M2 u2 s1 ] { & m, x7 X/ G6 t- ?5 e6 E2 k9 m! r
alert("密码提示问题不能为空"); 0 W2 C Q$ m$ @
document.sform1.checkask.focus(); & H4 \( T0 X5 B \
return false; 5 I) F( T5 |0 I
}
) ?+ Z2 t# _4 M* b9 l if (document.sform1.checkans.value=="")
8 R& c! K- V& m+ R$ N- z" m {
) D& Y5 X. F9 w+ ` alert("您的密码提示问题答案不能为空");
3 h. _# }1 k7 {1 t r M document.sform1.checkans.focus();
5 i8 B3 O0 D& `. n# n return false; + L- a# e1 f A" U$ Y" o0 Y \5 ]
}9 k& t+ h5 }0 ^1 B. w% C, k
return true;
( ]- {0 J0 V6 O( r
% _$ P- b# D% A7 |3 Q' I}
4 r. ?0 U5 f' i6 g</script> |
|