|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14411
- 金币
- 2491
- 威望
- 1647
- 贡献
- 1439
|
这个脚本对你可能有帮助:! S! ~( o9 `/ D; q' N
<script language="javascript"> 3 P# T! }6 g' q& s4 ?
function IsDigit(cCheck) 0 N. }7 t, w+ }7 n
{ " W$ H5 Y" y2 M3 Y6 I3 W
return (('0'<=cCheck) && (cCheck<='9')); / j4 R7 x }. a9 ^ D
} 8 y+ P5 A/ v* x
9 F% Y6 G# h0 z
function IsAlpha(cCheck)
# b6 b# v. |9 l; `9 n {
Q5 l) i& D' _+ A) }# O. X( z, [4 z return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z'))) ; @) H4 }* X' k9 m
} {9 c, p: d6 b+ j* q! ~, _+ L
5 W2 `, Y! ~( sfunction IsaNull(cCheck)
% D+ M9 f& G" V {
0 T+ U9 z! k) y8 s3 P return(cCheck != " ")
1 a0 A4 N* z2 Z; ^% W } / f) P( G) b9 e5 o, l6 o& C- A
& M% h! Y& `; T- |1 T" a8 Y
function checkform() 6 h( z" B) \9 ~5 Y, g
{ % c$ H8 J0 ] l1 p+ S) V
id = document.sform1.id.value;
" A9 K Y0 y$ M6 H( r4 `9 o7 U if (id == "") % N+ F t, X5 r( ]$ H
{
1 z0 B+ J1 W$ c, j" y alert("请输入注册名"); ' p/ I! [( v% u8 K* i
document.sform1.id.focus(); * B* A5 `3 d4 l! L1 \
return false;
! X% g8 |( A, Z/ Z0 {; s9 ^ } ; n( G) _6 W2 J- X6 N% M; i
, u; V0 o0 u3 g, q1 ] for (nIndex=0; nIndex<id.length; nIndex++)
' p2 ?- z( a, L0 O6 J { ; I d6 [) n2 q% m: v( c, [2 ]" N
cCheck = id.charAt(nIndex); * d, l9 K) n7 s0 m' F
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
; N, H' D: q+ o# F' x' ~" c {
+ ]! B; t5 e1 V/ w7 N alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
* e% `2 E# q2 I: ~ document.sform1.id.focus(); & {8 R# S8 u( u. k- d2 p5 j
return false;
( N1 N7 V$ r& L( u7 z( Q+ j } 6 j- D& _2 Q7 X( f
} ( O4 x0 |3 x6 c8 x. `) ?
chineseid = document.sform1.chineseid.value; " }3 i7 f2 G+ J
if (chineseid == "")
* Z, B# }) `5 q1 q3 _5 I; j {
' [6 x9 f0 l& w3 k1 ?. |/ } alert("请输入中文昵称");
( D9 ~5 i9 _/ a9 W0 S7 G document.sform1.chineseid.focus();
% ?( L# v% X+ Y return false;
6 C x0 }6 V) G# @- x9 y }
9 E1 T" h7 c- u+ r! n$ x9 Z password = document.sform1.password.value;
0 g" V+ A3 x" `4 z2 \: ?% `* P- R if (password == "")
& l1 y9 @% o; g { , J0 S F' ]' ]& P
alert("请输入登陆密码");
* x2 j3 B" x$ E3 u. M- }. n document.sform1.password.focus(); ( r$ t7 {& a; |. K5 u' U7 J V
return false;
$ K( m; z" V$ \8 c }
4 G D2 s0 e- @, o2 N password1 = document.sform1.password1.value;
; s* g4 }, e7 i8 B if (password>password1) - V# ~) K3 x+ z) W0 h
{
$ P! w3 j2 w0 D1 T alert("重复密码与登陆密码不相同");
0 z, p" x2 _ X6 f4 p document.sform1.password.focus(); ( Y; @5 ^. F, f7 e" F
document.sform1.password1.focus(); ( l0 b8 g8 \8 O5 e* V
return false;
8 j7 W& X9 W. r; _2 W' U6 t1 @ }
" L/ _/ J) A$ G9 |, |' v* C' Jif (password<password1)
& S' q4 f j d5 F& e9 s {
* ~' y& x# X9 k( i# ?+ _0 R" x alert("重复密码与登陆密码不相同"); ; D F0 j& m4 A0 T6 W; e, |! | F" n
document.sform1.password.focus();
" I, w3 v& U0 @0 ]0 a: F" H9 M$ ~ document.sform1.password1.focus();
, g) x% Z- G# d4 [0 [& z return false;
8 ~4 z1 ]" |; a) ~( k }
- r8 r5 ?) n$ y/ I if (document.sform1.email.value == "") # @5 R5 I; i/ Z% T! ]' c
{ / H) y9 x, U% Q2 G; W: B6 R
alert("请输入您的E-MAIL地址"); x$ d& W- {1 J [
document.sform1.email.focus();
# A" P3 R+ f2 l) y, c9 t- Q return false; 2 V& S' R, d2 I8 d. Q6 J
}
- _- m2 l" a5 l4 Q5 X. \
8 A9 H3 {6 m1 ~/ z9 N email=document.sform1.email.value; # k3 J$ f4 a9 }# C: Q* s* B3 p
emailerr=0 * u& E, G/ J3 \. b) k1 ?7 I6 u* A: q
for (i=0; i<email.length; i++)
$ A* @* ?- E: i# p! z {
( b7 y& s3 w) f( H if ((email.charAt(i) == "@") & (email.length > 5)) & ~3 C5 q4 B. v; q5 r: o4 E. {
{ f6 @1 M4 J$ Q2 s$ o
emailerr=emailerr+1
9 O9 a J1 k4 E. ]0 U3 y4 f } % ^1 g1 f* b6 y5 A w
}
9 y# j& }9 w4 i: v if (emailerr != 1)
) x/ _6 B+ L# f& X) q5 G2 T7 O {
2 L. ` h8 R* {2 R6 x- c0 V7 } alert("请输入正确的E-MAIL地址");
1 d4 d0 L# z+ c* o, n# j i document.sform1.email.focus();
6 [) j- |2 L" s' g return false;
* `1 u5 q' s$ {5 u: e1 J6 j }
. N7 A+ d) u/ Z4 h3 s0 k( o5 v ! E0 m/ c4 y$ q: S t0 S" _
if (document.sform1.checkask.value=="") ; E+ c: Z- c( g5 ^& r f; b
{ " ?7 ~2 H8 B- H- S
alert("密码提示问题不能为空");
9 k/ [0 G1 K7 O6 d" l3 P document.sform1.checkask.focus();
* F/ ~2 K+ u# Y. P, B' T. l0 W return false; 3 S D* M3 F3 O4 p
} ; d! J/ v6 E' {1 Z5 \2 d q
if (document.sform1.checkans.value=="") 3 c8 f) H: M G$ ^
{
' h/ l) n9 Q$ y# l' ~$ B alert("您的密码提示问题答案不能为空"); 2 P8 `3 a7 e* ]* _( c* _
document.sform1.checkans.focus(); % W$ w1 i/ c9 H! E/ [6 ~/ U+ l
return false; 6 X/ T: ]! k+ A; ^* v
}
* u, P9 n4 |; x! v: [5 E return true; , c* {' U0 a, u9 a
, N0 f3 [& m% Q8 [} 9 Q- `0 F1 F5 k3 }; D2 F, {
</script> |
|