|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14427
- 金币
- 2499
- 威望
- 1647
- 贡献
- 1447
|
这个脚本对你可能有帮助:
2 E/ W# n/ a9 ?0 X<script language="javascript"> 1 @# i* q, f% w% h6 Z! w
function IsDigit(cCheck) " H% O/ J5 o0 }! Q
{
5 R# x* r; k, M1 @' R return (('0'<=cCheck) && (cCheck<='9')); 8 L' I) {; o" _: W( I
} 4 k& ^7 u7 I: b; @$ N( j2 m- Q7 [+ O- A
8 p7 r. T# l3 K7 w& `# d U3 D& _
function IsAlpha(cCheck) [4 X2 Z$ i& v5 P" \
{
% H4 c9 N' Y# b- m/ M- F7 a return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z'))) 6 ^1 Q. F- p' q
} ( G0 G% {2 `' U' {5 L+ \
6 Q! K$ Z: ~- X% t ^8 b: Q. `3 \function IsaNull(cCheck) * |+ a8 M) t5 O* e$ ?
{ / ~5 R" Q5 `2 g% r; s$ N
return(cCheck != " ") * v* E; S3 N L8 L# T" a7 C
} k) v# j4 H' F7 S2 S
3 I: P! }4 S/ A& y6 ?
function checkform() 1 K5 d: G/ ~& l! L9 @
{
; Q! q% ]3 f0 A id = document.sform1.id.value;
& A1 H6 U4 L0 K& Z" _ if (id == "") 9 L# [/ T1 N0 |: F% m
{
8 G$ ~( g' P4 \# P alert("请输入注册名"); 6 ^1 O. ~, d# ~+ A1 f. ^
document.sform1.id.focus();
0 F: n1 ^9 M" y V return false; : ] K x' h! \( m! \4 \4 X9 y4 L
}
1 E ~- {: E' q; B/ N( C6 @
9 q8 r' x' M2 f! L/ h+ ? for (nIndex=0; nIndex<id.length; nIndex++)
/ O/ e4 d- m5 C! n( w8 Y { + D7 B2 M6 D- e% U2 C
cCheck = id.charAt(nIndex); * h& ?+ x9 u* o7 T: b
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
5 h& E; |6 e( q" U0 G9 f# a {
9 v8 R, P% o& Q$ l r4 `7 h4 g alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文"); 3 F' q2 e5 @+ X1 ^+ z7 s
document.sform1.id.focus(); - l, b# h n: I' ]! s$ e9 W
return false;
}& F& X- u b% J }
) ^* @0 W! P2 o6 T* w# K } 4 b' l$ d( q0 m. p: E; }( |" u
chineseid = document.sform1.chineseid.value; 8 x+ y: c4 J% X! |/ U
if (chineseid == "")
. p: ?3 H/ E% f9 w7 H+ ` {
6 X2 {& T& r: y {( R alert("请输入中文昵称");
. }6 A: @; Y: W0 D6 h9 t document.sform1.chineseid.focus();
1 V3 g8 W% B, b. L P return false; u) E, h' ]( p1 d. t. A
}
9 w; D& n0 p! L* ^# G; _& Q( H, G password = document.sform1.password.value;
' S: S( G4 f8 U' n& H if (password == "")
( E4 o7 j% K' m) w2 d {
8 N" U4 `7 a; H9 _5 T' b n+ f4 { alert("请输入登陆密码"); 9 l" J2 M) W4 v+ B. G
document.sform1.password.focus(); . _1 R b" h3 U
return false;
! o. I2 n6 A9 l" ?8 ?* v% C4 H$ ?% E- I } + T; [6 H" l$ e; H' Q1 S5 n8 y" ?
password1 = document.sform1.password1.value;
/ Q) `8 @/ ?$ a if (password>password1) 8 H8 q, T/ K% V3 z
{
+ [2 R, I" Q2 g% N) D1 n7 w alert("重复密码与登陆密码不相同"); " f; [' l4 x( T; {! X! e
document.sform1.password.focus(); 4 p( ~8 m* Y; x- Q+ L' ?% m5 g3 b, @; m
document.sform1.password1.focus(); ! }) v. L6 W6 C3 ]) J: e, V- C
return false;
+ Q" F3 r2 o% U) a }
k0 H8 L) R8 I+ V; qif (password<password1) : M* v# V2 \7 D% g: \" a; a c
{
1 s. F8 z- z# Q0 ~0 k, E alert("重复密码与登陆密码不相同");
4 W' W6 h7 P ?' M: V document.sform1.password.focus();
8 `0 ]- o0 R5 @+ @ document.sform1.password1.focus();
% G' R' ]! p3 X& z/ d return false;$ w; M# f( b% G" U
} 5 I! U4 `1 p, `6 b# V, K
if (document.sform1.email.value == "") + T% L2 s/ a1 s
{
# V: u7 e$ D* h, Q% B- k alert("请输入您的E-MAIL地址"); 5 {1 W) y$ R) U r0 e4 g# ^
document.sform1.email.focus(); 9 O" y: P/ @: q2 \; P1 B
return false;
+ [, z# L/ s+ R }
1 Z/ m) M# c4 K & j! M% E; @7 _& v( j8 m1 x7 V
email=document.sform1.email.value;
+ N# y& o: o( V/ x% l$ a6 [3 A emailerr=0 & l6 ^. c! _/ K# T( z
for (i=0; i<email.length; i++)
, h6 P$ Y& D$ t! C% H { : r+ ]5 T, h) Z2 ~8 B# x4 e: I
if ((email.charAt(i) == "@") & (email.length > 5)) 4 f @9 `! H Z3 m
{
0 E( C k B8 a3 u) | emailerr=emailerr+1 ' ~' T, i3 ~ Q+ A2 l$ n
} 6 ]& ]7 g+ x/ S( t+ G9 s$ Y
}
' Y8 q0 b+ t; s y if (emailerr != 1) 3 V" ^1 y1 J% p/ M
{
: g3 S4 |# l. w1 R alert("请输入正确的E-MAIL地址"); 5 Q6 k1 z& x0 W0 p! T) v8 p" |
document.sform1.email.focus();
+ |! S; q( r$ C+ r! b& z4 E return false;
" \8 j7 [; f! i8 I& n! ^" l: j } + @4 a8 n$ ~1 S) F
! i5 ~: V: H G; G1 } if (document.sform1.checkask.value=="") 0 I. q; r4 p5 G X* B% \) k V
{
; A1 H0 @1 s _* ` alert("密码提示问题不能为空"); 4 Y) ]) z9 F" n a6 u
document.sform1.checkask.focus(); , J- y- Q, Q* g3 ~/ X+ t% d0 A7 Z
return false; ) T( p' o3 U- _; K. t
} \" W$ N. ?, r3 Y
if (document.sform1.checkans.value=="")
* R1 E8 Z6 S/ B1 m2 S$ m5 f* i; g { % j4 ^6 P- |% A& {0 b R
alert("您的密码提示问题答案不能为空"); 0 Z! g/ o( H- ] Z' \2 N U, d% H
document.sform1.checkans.focus(); / }" s; D* _. U" n* h
return false; 6 b2 @5 p4 n4 o9 Z; p
}
J* ?( ?7 c. [, |- ~. i* y+ W/ C return true; ; ^% }. s' m) ~! |: U1 |/ p
( X% Z) c7 p, ?7 K8 j. y+ ?6 H. A- B
} ' G6 u4 {' i! i/ Y8 W
</script> |
|