|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14325
- 金币
- 2448
- 威望
- 1647
- 贡献
- 1396
|
这个脚本对你可能有帮助:/ f0 @1 ~0 h2 B- E4 L3 `6 x
<script language="javascript"> 3 ` r1 U* Y1 U* o1 G) |
function IsDigit(cCheck) 7 y: I2 P+ n: L& G* h% e
{ ~) ]1 m9 ~" m9 M" |% }
return (('0'<=cCheck) && (cCheck<='9')); 4 o2 g4 x s0 q: y- Q2 I
}
4 s- S$ h/ ?6 D3 F2 M5 Y / `: C h' Y: m* @0 g& q
function IsAlpha(cCheck)
' |0 y4 J2 K# R2 x2 }5 { { 9 `. K+ m$ w, v! e
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
0 S3 e' r' t. z* _0 d7 Q, A }
: i m, J6 n: x `/ f- Q) k" @
+ e5 o9 A$ x) L s9 lfunction IsaNull(cCheck) 7 i2 p6 [; k! T* E1 E/ t" ?
{
& |) ~7 d ~# P) } return(cCheck != " ") 7 _" H8 d" l* o" L
}
6 |. E4 J" k: k2 [% E 9 b! S2 Z' o0 M& Q: m
function checkform() , L# P' {( b4 p7 u
{
" l0 T) [2 G; P3 I1 [6 b$ U id = document.sform1.id.value; : i. w9 }$ C4 X& l% ?; X) y
if (id == "") 1 P: F6 \6 n! j! ]1 F% K
{
; h# k* ]5 R* S alert("请输入注册名");
0 f" [2 p8 z+ y, @* B- V% y3 c document.sform1.id.focus(); 3 g ?' m1 e6 M9 U7 U5 N+ V
return false; 9 v) H% s/ R% o2 J% V
} * x. M# f* u8 A4 f. m( F6 i2 T
5 |9 |& p! F# j' P9 |3 Y1 W- } for (nIndex=0; nIndex<id.length; nIndex++)
3 v& k0 K/ `, a& g { , x/ K3 o5 ~- v( a2 ]' h
cCheck = id.charAt(nIndex);
& O) d( S# T2 g$ J6 w if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.')) & P1 Q0 Y$ n0 ~8 g" H
{
, w2 [, @( @ y9 \ alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
) m) b/ X0 f& N, A document.sform1.id.focus();
6 ~* m9 S! {/ `* p; o return false;
?3 C( s( A! R3 L+ _( X; h }
4 l6 z; D- g# P) J( K) | } 4 }4 w& c9 ^6 _# V( V! u
chineseid = document.sform1.chineseid.value; , ~, [# M6 L, x4 k( i
if (chineseid == "")
* e8 l* u" i0 e { 4 o$ g1 s( u) p% t* z+ C
alert("请输入中文昵称");
7 C5 O- _! V+ t$ ]2 I5 m7 N% ?- \+ D: B document.sform1.chineseid.focus(); 4 ]/ t' \2 |" M* b, d/ {
return false; " q y0 f) I( A
}
% q: a4 ^1 P9 ]( N password = document.sform1.password.value;
2 L, ?& p0 t0 y6 K8 p3 ] i if (password == "") ( k: T. ~7 M; y& p7 a, N% q6 V
{
3 ~2 \5 Y) y: I3 V, i( { alert("请输入登陆密码");
Z3 v& S( \! w' \/ s2 P document.sform1.password.focus();
3 r+ b2 B/ D! E return false; ! Q9 s! l6 R' N }+ U
}
( c2 `8 k4 D) m4 o: a password1 = document.sform1.password1.value; / k3 \* @* Y0 x9 s. V* [" g5 L ]
if (password>password1) 2 Q( o7 m1 h3 C0 U& x
{' T# I+ c. l3 D$ ]# V
alert("重复密码与登陆密码不相同"); 5 B5 C* w6 Q5 \
document.sform1.password.focus(); 8 ^/ R# C( b& R" Q% K7 |, X) B3 X: L
document.sform1.password1.focus(); * Y6 e4 b" b, s {
return false; X- F$ M, c" u# \8 A
} " x5 K( w+ r% p0 d- @( O
if (password<password1)
* K& }7 c5 ?& P: f6 V1 r {. h' b- P2 ` I0 Z1 m
alert("重复密码与登陆密码不相同");
5 P& B. Y2 \/ Q8 R document.sform1.password.focus();
& p7 u, \# ]5 \: X6 j/ j) c( N- f document.sform1.password1.focus();
& m1 F8 w% y2 ]/ ]& z+ L2 Z return false;
R0 S% F1 t/ X4 }) P' S/ b+ u: T0 E }
% ?8 Q2 q, i9 ~) y: g3 `3 L$ X if (document.sform1.email.value == "") 3 q0 a: F& F2 `
{ 9 e9 v8 g+ D k0 E5 W, ~
alert("请输入您的E-MAIL地址"); 9 s6 S0 X$ _% u& R1 A* S
document.sform1.email.focus(); ! u3 _0 R; g0 F8 X0 b4 u5 x) q
return false; Y" ?$ U: {/ O8 V) T' L$ U
} 9 _8 \& P1 T8 P& d* n
9 v9 @; d. H" l1 Q' N6 Q* \
email=document.sform1.email.value;
2 r7 W* \; Z7 G$ j. x4 v+ e: Y" D emailerr=0
: q; ^7 i* R- Q0 a: t$ i for (i=0; i<email.length; i++)
4 |. t0 t* A- a% G {
# ~1 Q6 F2 ]) _" P if ((email.charAt(i) == "@") & (email.length > 5)) - A$ j7 Z# M% Y% S. h/ [* S! g2 y+ @
{
" p% r0 @4 }& f4 B! z, z emailerr=emailerr+1 7 U8 n2 J' o- H* C" L
}
& S: U: X0 h6 E& L# S& E/ D( b } 9 x& y6 D( Q9 U' J9 d- E1 L2 z3 {; G$ y
if (emailerr != 1)
3 K+ t% J. c2 e0 e, J {
9 D0 z: V& a/ u8 V8 B% [ A( ]4 p alert("请输入正确的E-MAIL地址"); 6 t/ u8 z7 E/ l6 [8 v
document.sform1.email.focus(); . E" G$ @2 ?9 n
return false; ( g4 h2 A) Q+ M: f9 L3 X* O
}
/ w+ Z" i" a3 L+ m5 j6 ]1 @
@" D; W! I: {( g V0 H3 j if (document.sform1.checkask.value=="")
( d8 p( s/ m2 e- \+ l9 j { 0 c2 c, v' N, C8 M! v$ Y9 S; N$ _7 v
alert("密码提示问题不能为空");
9 M$ q3 B% Z$ h4 i2 u8 u7 X% E document.sform1.checkask.focus();
' V" s, v0 q1 V4 j return false;
* Z+ A8 ]# P# z. ` }
9 l J r9 Q. K* B+ x1 ` if (document.sform1.checkans.value=="")
9 L5 w! R0 G4 I; Z8 b5 N2 Y# O { 9 g& O. j( P2 _0 I
alert("您的密码提示问题答案不能为空"); , U/ Y3 `4 L! k) Y5 Y j. R2 q
document.sform1.checkans.focus(); . K+ h4 g& y4 K8 @$ G1 k
return false;
; W) g9 @4 Z4 V# g6 r% C }
2 h7 Q3 n& W5 y# }# w& [ return true;
" U# Z q# \. K& S p. G 2 N8 W0 g) z8 @8 l2 l7 P7 M& \' q
}
. I2 p, s' ~% Z% }4 I</script> |
|