|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14423
- 金币
- 2497
- 威望
- 1647
- 贡献
- 1445
|
这个脚本对你可能有帮助:, V' C3 x7 ^- v4 _9 r T
<script language="javascript"> ; b5 k& Q( N: m' d2 R% r
function IsDigit(cCheck)
. M( U9 {& Z% b/ N: |& O2 P {
6 \" I5 P/ i) I return (('0'<=cCheck) && (cCheck<='9')); q: t4 P2 P2 t) ^- e T
} ; V6 w6 j4 h5 j( E
: u H$ v+ m( P2 n tfunction IsAlpha(cCheck) & f5 H _. B( n
{
4 h& S3 `9 q- J return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
$ r0 T# }) o: `+ P3 ^ } ) y1 g8 G! S; D7 H
2 \$ [7 T5 K& `/ W1 B4 |- ~! ifunction IsaNull(cCheck) 8 }7 [: [, |9 j# X9 f
{
6 a( Y) j+ o( N4 [ S return(cCheck != " ") , ^% n) [/ M* g5 O' p
}
- S% O0 s, I: C9 R* L' _ # H9 Z6 C w. `$ Y. C
function checkform()
" h/ x9 `; n6 N1 b2 c{ 4 r3 Z. P' W' V2 \5 l
id = document.sform1.id.value; $ @4 e# T5 {" S- N3 z* w! f, b
if (id == "")
" f6 ], f# ^3 |" I% c2 Q {
$ Z4 q9 y: E; f' ?* f& H+ L alert("请输入注册名"); $ E* w* t( k" t; s5 X
document.sform1.id.focus();
& D1 V2 g+ a* w8 m+ v& l5 v return false; 5 X; p# A( G0 \! I7 @ F
}
z1 K' @4 y4 w9 ]( c# i. w 9 D* `% ]- A; `' f% c5 i- M Z
for (nIndex=0; nIndex<id.length; nIndex++)
: ~6 B- ]+ y8 J! s' ^9 b2 m/ l {
5 _5 `) [8 A; _, _3 Y& X cCheck = id.charAt(nIndex);
* G! J& m4 X. z) l" x7 W if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.')) $ E2 G2 F+ }0 Y6 p/ U6 n( @
{
9 [* v# V0 @" ? alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文"); 6 H8 ^& e0 b2 e$ N8 K# M6 z g
document.sform1.id.focus();
0 P1 k' A; r9 _" D- J# e) `: y( T return false;
, @) a7 N- x8 _4 O$ \ }
: H4 k3 Q+ m: D3 J0 e: Q7 S$ o" V }
- H2 C5 ~7 p4 k- a0 e4 n2 Y chineseid = document.sform1.chineseid.value;
# J1 O" L) K! D* [. ` if (chineseid == "") ; N* ^9 v6 Z7 v# i
{ 2 Z8 ]! R* F8 \% s) z" }0 O% A. e
alert("请输入中文昵称"); * h+ X9 D$ x- A2 y
document.sform1.chineseid.focus(); . }8 h9 @' _- w3 w1 B. z( c O
return false;
, U! P5 n& w7 d& C9 [! } } ; x. i* W9 f6 R- |
password = document.sform1.password.value;
$ |' f" `4 O1 z3 H7 I6 N3 W if (password == "") 9 o2 H* Z+ t! G
{
$ W% ?) A0 f7 l alert("请输入登陆密码");
6 A7 l6 ?. T( ]/ J7 X: V document.sform1.password.focus();
# B* i. y. U+ |. l: T return false;
* _$ T9 c$ w+ J4 [2 L* P. @ } . w2 c1 G/ G0 t
password1 = document.sform1.password1.value; % Z5 c9 D- ], k/ }, z
if (password>password1)
; L# b8 c5 L5 o& | {- K/ Z* N# Y! Q2 L' }& @) ]
alert("重复密码与登陆密码不相同"); 7 Y; I0 c1 _" x* N9 N' A [9 G
document.sform1.password.focus(); ! }8 E/ |3 s. o1 w
document.sform1.password1.focus();
6 \! }/ Z5 t+ _# }# B return false;7 H9 Q, s' [3 s; ^5 Q! |
}
4 L& \9 P+ d( H* v$ Jif (password<password1) : [9 z& Z# s& ?4 N8 D! y
{
- L2 C# X, o. l# @8 c alert("重复密码与登陆密码不相同"); + o% `1 j$ n c
document.sform1.password.focus();
/ X% B) c7 Q e8 q4 L" ^' V& W% u document.sform1.password1.focus();
5 ~# q4 ?9 Z# e9 \& G3 U return false;
2 H* R/ y; a1 M4 @: N; l- y' g$ a( M } ( O8 k! V- V1 a" j4 S3 n5 Q' h; h
if (document.sform1.email.value == "") 6 r% Z- v2 M" R: J: B0 D9 x' x
{
* S- U! O! o/ |& m/ N2 n5 B3 Q alert("请输入您的E-MAIL地址"); , ^- t* L1 S" I' @2 I0 h% c5 s5 E
document.sform1.email.focus(); ( Z& M7 K2 W0 H. ^, b
return false;
7 a8 |$ C& b0 G1 d } / p) }! E5 D" j0 w( g( {6 G
' J# m) j2 B& [$ k, `/ S email=document.sform1.email.value; " m D8 J- f ]
emailerr=0
1 l4 L Z0 s7 A# W3 j8 u for (i=0; i<email.length; i++) & ^, o, f w' t" Z+ u3 X. C
{
9 g. j( `$ @9 Q, R: H if ((email.charAt(i) == "@") & (email.length > 5)) l F$ I6 r l5 a
{ & `3 S3 t2 a/ T0 S0 k1 _& I
emailerr=emailerr+1 1 R9 M/ C7 K5 U4 Q# ]. U+ e( ~
}
) |/ e) b: R) H } 6 T" [7 U H0 S2 ^0 p. w
if (emailerr != 1) " t+ B q3 b! ?8 w% F
{ 5 O6 ]% g7 c$ ]! R. O% G: B# Q
alert("请输入正确的E-MAIL地址"); @+ T5 C3 `7 [8 Q$ t" T( v' F
document.sform1.email.focus();
0 A ~5 T8 _! e& Q! n0 m6 Y return false;
3 ]/ s+ l% j0 s/ j4 ?+ \" t1 O }
* R; I2 \+ `# p$ m+ X
) A7 @' K/ z. w5 b1 J; a3 i if (document.sform1.checkask.value=="") 4 K" [4 T5 W. h# o
{ 3 A ^, m, H, i1 l2 R7 X
alert("密码提示问题不能为空"); 1 w N5 ]. w( ~. F2 D
document.sform1.checkask.focus(); % ^+ D9 u0 K# b2 Y6 i6 e
return false;
% T# s8 r! F7 p9 R5 b }
! ~" N( C& Z$ `! |- h0 | if (document.sform1.checkans.value=="")
! m, p+ U! Q1 @, O2 `5 k0 Z6 g {
9 p5 G. L0 J: R9 A2 T alert("您的密码提示问题答案不能为空"); / a* C% n+ c; ], W P
document.sform1.checkans.focus(); / s& I: o+ S8 i7 X+ q4 k# E }
return false; 6 X. x$ s7 v2 |& }3 w5 s/ L( L* Y
}: l' V7 m# ~4 q5 `0 e
return true;
f' m+ a+ J* C) O& k. T 4 m/ R6 F# v. g% s+ r! N5 {( {. B9 U
} J# L" T% A/ Q a( d1 v
</script> |
|