|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14397
- 金币
- 2484
- 威望
- 1647
- 贡献
- 1432
|
这个脚本对你可能有帮助:+ S2 s1 Q/ K/ w
<script language="javascript">
: K* O: ~* t% |& v% `$ L- rfunction IsDigit(cCheck)
% h" U) V$ A' S L* v/ E {
. `6 n: Y( }0 U" ]/ \/ u return (('0'<=cCheck) && (cCheck<='9')); 7 J8 t" L1 ~1 o& e
}
! J0 f5 ~7 I) o1 _ ( S% z) P1 @4 n, p9 ^" y ~3 _
function IsAlpha(cCheck)
3 m8 u% K) _: D& A5 G { 3 X& V1 @- R- f4 l- u- v
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
! Z1 x! S. V& x t& N/ s0 ^4 v }
7 T* f# [$ k, I& Z; M6 M 6 m" V9 u$ }! D3 h1 D# O
function IsaNull(cCheck)
: g- t3 A c0 T# s$ E1 q" E {
1 e$ p& ?9 Y9 p return(cCheck != " ") - B1 W: ]3 o: G6 t+ T* T
} . p. f) x7 ~4 L+ w. M! q9 [' t
' B; N+ y. `; ?, V$ h' x9 r" |function checkform() & h; Q' Y% V8 v
{
' r! f8 F v! D id = document.sform1.id.value;
7 k# i# x N/ Q+ j( Y if (id == "")
0 l: Y7 C, ~# F2 S { - K9 W3 {4 ?! w- y
alert("请输入注册名"); ! D& o; ^7 m8 Z; ]& w% \' }/ U; s
document.sform1.id.focus(); - V- z' l3 d7 X% J9 c i
return false; % V0 E9 j' g9 `8 J
}
* ^$ F# s2 O/ H6 _9 f. U1 e
" o% D& K$ E6 |8 ]& d( B2 r, @$ U for (nIndex=0; nIndex<id.length; nIndex++)
- C$ R1 c' _& V8 f+ G {
- K2 Q1 S1 w, s8 a cCheck = id.charAt(nIndex);
+ j0 V9 b, l% a* u, R; ^( b6 w2 R if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
) G1 ^% |3 [4 I3 g$ H0 g8 P {
, \' c$ J; n/ K5 X; {4 E" O alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
6 K o4 R# l( ~3 ^8 A4 {: y document.sform1.id.focus();
# H: C$ G1 t4 M2 m& _ return false; / \% P* W) G; U2 K1 S4 ~) V0 [5 C. u8 }
}
2 d& w: H$ h6 m9 H5 z( R } # R5 }% X: U2 A7 Y6 X' @
chineseid = document.sform1.chineseid.value;
5 V" \( B. y/ Z6 m if (chineseid == "")
* G* U, k4 f7 R. C { 5 M+ h0 b7 l: o9 c
alert("请输入中文昵称"); $ b) h/ y+ A4 z: Y
document.sform1.chineseid.focus();
( [" n% |5 O' ?' [7 U) Z return false;
- Q/ X0 C1 K) w T- M }
0 r' k/ }: G- m R y password = document.sform1.password.value;
8 x, Q8 i! ?" O% n if (password == "") * P8 S, J' X6 K. f
{ " }0 l- c4 }+ P! Q
alert("请输入登陆密码");
& a J- X- x2 }' h0 E document.sform1.password.focus(); - i; G9 W9 U7 i( o
return false;
- g$ k2 U' l8 g$ \" ^/ `, A } % f* i4 U5 v6 Q# U; p
password1 = document.sform1.password1.value;
: w6 |# k/ b2 P' c) ^+ o if (password>password1)
5 l: I! S. f# H& w% k$ J {( N& \7 M) V' x X. ^0 L, f* D/ g
alert("重复密码与登陆密码不相同"); 3 Z3 ^7 s( P; ], F9 Q0 m) V
document.sform1.password.focus(); & M0 j! E7 o3 E6 ]7 m+ Q
document.sform1.password1.focus(); 1 D+ [' W( z+ y5 q+ ]5 E' O
return false;
3 {7 w% t- s' `8 f5 G4 Y }
; y. Z( D! e. W+ R" N$ [if (password<password1)
) k) R3 a" m+ T$ R* q {3 d+ e$ T: x6 p2 I" d
alert("重复密码与登陆密码不相同");
" E2 W( p+ t) f* Q( \7 s document.sform1.password.focus();
4 o$ B9 B# r- i& ~8 k7 A0 s' `# X document.sform1.password1.focus();
& u& q& X# c" d* ]/ f return false;& U. H3 @7 y2 H6 j
} 4 l4 Q& p0 Z$ Z& A
if (document.sform1.email.value == "") 1 M5 x: u; L- U8 ^8 i5 _
{ ( x) c1 B! [8 Q9 A
alert("请输入您的E-MAIL地址"); 8 p @7 K( v$ \% e5 q C
document.sform1.email.focus();
; J4 ?/ c% z5 h% ^5 w# |* Y return false;
" d Z4 W0 k/ k) s }
6 W- \2 B$ r* u- Y; R6 @9 B
2 O! ]4 f1 x9 e3 D5 L. R email=document.sform1.email.value;
1 r& t) K" }% _0 m% q emailerr=0
. `: I! J1 }* Y for (i=0; i<email.length; i++) / m* w, G# z+ p% Y- S/ V- y2 z$ R4 J
{ 6 a1 d" j9 J* d
if ((email.charAt(i) == "@") & (email.length > 5))
7 l& |! j- J+ ~' e8 X {
9 T# p0 b* f% ~& h* l% X$ l emailerr=emailerr+1
" n& [' d# H$ \7 [6 M }
0 G9 c6 n+ m0 I& U* i }
7 Z5 h7 a. [8 u2 D, M# q2 r if (emailerr != 1) * X: e! X, ?4 ?3 [: s
{ . k! W5 u. N4 r% ^( ^, n; e
alert("请输入正确的E-MAIL地址");
6 d& S9 O; a) R& P2 I document.sform1.email.focus(); 4 m- S# ^! N5 L8 c& }6 m
return false;
' w5 O/ s2 O o! k% I8 @ } . C* z# Z) C, @
1 E+ N, Y$ a4 p) B# U5 p5 \: h if (document.sform1.checkask.value=="")
3 ~* E/ j5 B H' @- ~ { - A- K. c% y/ T/ h% p ~1 G4 e
alert("密码提示问题不能为空"); 3 _- P$ J$ Q0 a* I) m
document.sform1.checkask.focus(); $ T5 r1 G/ ^' t- R' s1 L: e
return false;
# c: D: |+ V; q/ a ~ } 7 W0 z! m$ C( g: [; D* C
if (document.sform1.checkans.value=="")
3 w3 E0 H+ O) ~; v { 3 [0 c0 i5 R7 x% `
alert("您的密码提示问题答案不能为空"); , |) ?, s% ~* x0 Z+ G1 b! }
document.sform1.checkans.focus(); % i1 H3 c: W5 O5 ~1 Z r2 U
return false; , [) _2 Z8 x4 J/ {0 e5 b
}0 X6 J. O5 v. g3 K4 J
return true; , J e0 s: ^; ?' [ T
6 [8 k! Z' L! J) N# H; L} ( E5 r% M9 Q6 l: q. [( r
</script> |
|