|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14411
- 金币
- 2491
- 威望
- 1647
- 贡献
- 1439
|
这个脚本对你可能有帮助:9 H; f2 M, M/ |* `7 ?
<script language="javascript"> j# Z$ K9 `; W, |* f5 _' P
function IsDigit(cCheck)
- |- |& q* m2 P* @. w {
& T% N4 j% @2 C: m1 i return (('0'<=cCheck) && (cCheck<='9')); 5 }, O2 R9 X( b" l9 \/ \
} 5 ]% r# g o( m' b! x+ ~1 h7 S
- O+ h! ~% P! J9 I) c3 x
function IsAlpha(cCheck) & v" {3 `0 m6 X0 R ?8 w! w
{
2 `+ o! J4 d2 V( Z( ~ return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
) }2 Q+ T& l% M; _ }
@: R8 [/ \5 s% s6 M( B# j) a
( y8 f' x8 R: @function IsaNull(cCheck)
8 [4 c) i' D Z* G3 b | {
' I S- w# N- J; [/ P# m9 b return(cCheck != " ") / q( \" G9 M! T K5 X2 |
}
; L9 K# ?6 M) n& s$ g* J$ {
- V/ y- ~% ^ d8 j0 W& X# Ffunction checkform() & n% }; l: G) k( R
{
; \8 L" b. w5 G5 v; n+ y a4 a id = document.sform1.id.value; ; l k+ k8 r0 A; s6 V( h( Z ~
if (id == "")
3 m& C! {9 n8 H, v9 x+ h2 ` { P6 ]( a* R. c5 [+ `
alert("请输入注册名");
) E, m; J' [% q document.sform1.id.focus(); & M! z& O& r" G1 {' V r2 P3 q
return false; 5 M& ]; ?: |3 f. w6 s1 ~
}
# j1 C7 h8 G; f1 p # b5 ~5 X& J+ _! T# r
for (nIndex=0; nIndex<id.length; nIndex++) # {* d5 o$ K; o: E
{ 3 }, x. h+ P1 k; D( G6 E
cCheck = id.charAt(nIndex);
1 r5 F Y( g: w; ?$ p. {3 v if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
g; h- o0 r& \5 @4 L2 R W- K; f4 v {
+ p! T; r- W! R* w alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文"); ! r/ O1 H( \" V" U! i5 J! T. n! h
document.sform1.id.focus(); - ^; O) A$ H0 Q
return false;
" k" m R( y/ p+ U }
5 _" Y* c, l4 J5 A* P. b } 8 q9 P! {- x) @8 y3 K! E" r6 i& h
chineseid = document.sform1.chineseid.value; 0 {9 B! G P4 L9 v
if (chineseid == "") ! k. u/ }0 H' a+ ]! X2 E
{ , d. v; @" |! j; [9 A: a
alert("请输入中文昵称");
# P3 q; n, i3 D$ O- c document.sform1.chineseid.focus();
. r+ O7 P+ D! Y. U2 ^+ v2 L! w return false; # d5 x$ y x5 _, l' J
} 6 l8 L' q" M5 o8 `
password = document.sform1.password.value;
( J/ Q C2 X9 B2 N) _$ M if (password == "") 9 t, C0 v: E' B% `1 u0 f( f
{
$ z& Q4 H0 J8 |5 [5 X' B1 n alert("请输入登陆密码"); 2 U; C: p' j9 }# f8 H
document.sform1.password.focus(); 6 F8 l6 h& r) E2 C: t; G! A
return false; : q0 ] g C( ~/ N5 m3 Z
} 2 n+ _( C+ n* \0 M
password1 = document.sform1.password1.value;
9 L0 ], Y& S3 s/ X0 C if (password>password1)
/ Q, r5 v/ p O) Z2 U1 H {. n% {+ v8 M& k' U& @
alert("重复密码与登陆密码不相同");
! C; l1 n/ Q0 e/ K8 q document.sform1.password.focus(); + a2 h; R8 \5 d# U4 z! ~
document.sform1.password1.focus();
! h' ^+ D$ ]1 C9 C- e return false;
- e" K2 W5 i' L' n$ e }
0 \/ M; @% R; h9 p/ x2 U1 H0 { Qif (password<password1)
! H! x# m U/ V. O" C {
$ Z ^$ ^/ t5 N- j* L' x alert("重复密码与登陆密码不相同"); + r* T1 T* X, p& P5 W2 r1 @3 k! Z
document.sform1.password.focus();
* `$ r, p; A1 }6 A& Q& T document.sform1.password1.focus(); 5 {) j. P; x& G; r1 P6 K
return false;& i& M2 h7 T8 K1 w& @* Q
}
4 r# I @5 l8 m) P. y+ Y0 w( i1 y, F if (document.sform1.email.value == "") 8 K! t& b- h, f) H' X$ j
{ ' h2 E/ g" R! z% |5 A! E# L3 q
alert("请输入您的E-MAIL地址");
* y# W! g# {# K. T) Z; F. C document.sform1.email.focus(); ) W7 @. f8 _6 D# `# d' Q$ i8 \
return false; 9 G3 ]; M! J# S; ?
}
+ n* ?) U$ ~) h' \ 9 o) S' a$ u- P8 _4 I4 W% i# S6 G
email=document.sform1.email.value; + r7 u" f$ q: p6 G0 {5 M
emailerr=0
# z# a' ?$ H! p7 C* ] for (i=0; i<email.length; i++) * k8 F2 z+ F1 ]4 k8 K% {8 X5 i; k8 I" _
{
; w1 `0 |! i2 D4 f' O if ((email.charAt(i) == "@") & (email.length > 5))
n8 `9 v- v6 C- X5 b+ N) L { ( x+ t0 K0 N& L6 ?9 J2 a( L
emailerr=emailerr+1
/ C: H3 H) U. G6 m/ x; h! u: j } / P; r' _$ K/ t& H+ i
}
/ p' {7 t/ ]6 b" _# {4 i; i if (emailerr != 1)
7 S% p! e2 G8 d {
2 }$ Q# w4 D. T' |6 h- j alert("请输入正确的E-MAIL地址");
) d, K. e' z5 | document.sform1.email.focus(); % f! w7 `* q' S4 F) s2 D6 L; }
return false; 5 ^+ r7 O$ u1 ]+ M" `2 g# @
}
) x+ N- y' w9 h6 R
' p ]/ m- [& d7 ~! } if (document.sform1.checkask.value=="")
& l, V* k. X# b0 ? O { & A( I( s' _, r& R, I" h1 a
alert("密码提示问题不能为空"); % w1 G8 i' C7 c8 s$ i! U1 I
document.sform1.checkask.focus();
! }' v0 u8 V5 c! t3 X return false; # ^; a& C* s3 }* I
}
' i" l5 o w/ a' p% l4 R6 d d if (document.sform1.checkans.value=="")
' u( ` x# m( r* V {
* m$ R m/ W0 }% a) G% A" l alert("您的密码提示问题答案不能为空");
D' ? t1 J3 O! M5 b: X# } document.sform1.checkans.focus();
7 C. q5 a$ x* s5 \0 [) F0 m return false; $ P) ~- m( @5 b2 B+ M
}7 O- J5 M/ u3 t, s* S
return true; & `* b" t. y" M, i" y
9 Y- _0 s q$ e* c$ J( q' }6 |) t/ O9 s}
4 o; [6 R" @$ y; {</script> |
|