  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14221
- 金币
- 2401
- 威望
- 1647
- 贡献
- 1349
|
这个脚本对你可能有帮助:
% ~3 C2 ^/ w i3 v<script language="javascript">
6 K5 `1 h5 C( C) y6 Qfunction IsDigit(cCheck)
+ ^6 L) D- g& x! z \7 B {
% C: g& B$ X* t' C1 ~ return (('0'<=cCheck) && (cCheck<='9')); # D& r( L# l; M
} . |$ F/ C/ K' | k5 D" [* m; K
. |8 I2 d: h) \3 bfunction IsAlpha(cCheck)
' M2 g8 Z/ j& ` { ; j# v0 b; v) X* T
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z'))) ! |5 B6 B$ a# z0 Y# Q' [
}
! X! [3 m' ?+ t" \+ y K2 k$ x7 G* R7 k n; [
function IsaNull(cCheck)
$ s: N R5 f" K: W { 8 H& e% p$ ]" w
return(cCheck != " ")
' p% t h/ f: h9 N" | }
. a5 e7 g) _/ f" s) P * ^4 i5 h0 E' U7 e
function checkform() 5 `/ e+ k' x9 I( J" M4 ~3 R0 i
{ 5 b5 S1 Q$ j% M
id = document.sform1.id.value; , m' a9 m2 }# `/ G0 D' ?
if (id == "") 7 F. X' P2 [5 g9 N7 |1 U
{ ( S0 q i: S0 F; E/ Q
alert("请输入注册名");
- q" f$ a: O/ X6 ~2 H document.sform1.id.focus();
# N) I$ V5 D) w8 C7 t" V return false; " E/ I7 O. @& Y* h
} $ _% n$ z/ v8 S9 _% S7 x0 {
9 d5 A) L+ ~0 W! ^6 u2 b7 o for (nIndex=0; nIndex<id.length; nIndex++)
6 U6 N" A( G* o& H' ? { " ?1 o! b1 g' i0 b
cCheck = id.charAt(nIndex); ; s$ N4 Y8 o$ t1 N7 ^
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
7 Z% Z- H4 U! i( C6 K { + j9 q6 q# h0 m
alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文"); % i; k- x" F$ T2 w& f
document.sform1.id.focus(); & P g/ G+ H0 b
return false; + A/ ?- J8 y; W5 o% _6 o6 ?6 _
}
' d9 Q' H a% D6 l% p- c) A } 2 {5 A, V7 R. J; l
chineseid = document.sform1.chineseid.value; $ |2 i- l9 y$ U
if (chineseid == "")
6 \7 Q1 K2 ~% @; O: j$ ]! M {
6 o6 \$ o9 M1 y6 L4 R alert("请输入中文昵称");
. H3 ]4 U- s4 r+ ~. a: }$ _ document.sform1.chineseid.focus();
9 j0 I( @6 F% o6 b9 ?* a return false; , J5 R, ]- ~$ B" j- x3 X
} . K( v. z! s- R+ t |9 _% J
password = document.sform1.password.value;
7 W: Y+ G4 O& e& X! g$ X if (password == "") 6 ^6 e3 A P6 |3 Z
{
$ N# s' ^; ~0 @ Q) Q, V$ m alert("请输入登陆密码");
/ H( l# V' h- z" z7 N- P document.sform1.password.focus();
2 S; f/ G! i, q9 c8 G return false;
: j0 R: ^! |7 e2 C& i$ O }
: b3 w* s9 R6 d3 _, _ password1 = document.sform1.password1.value;
! ~" x( b% |# y4 ^! G8 L9 s if (password>password1) # [. ^9 m' ^& ~; ^0 B
{! m' z2 c. w' l+ k8 e) Y+ j. U
alert("重复密码与登陆密码不相同");
& [ U& [ m# ^! b document.sform1.password.focus();
/ B/ u4 f% u+ ? v" I document.sform1.password1.focus(); 8 I0 t, z) _ o' ~
return false;
1 z0 P+ ^# Q" o& ]$ b } 7 O/ C4 v9 n+ Z0 u. K
if (password<password1) : k# j1 N X) z# W: ]
{! G, D4 f# k6 m. Y! r8 f9 d9 X
alert("重复密码与登陆密码不相同");
$ {: f# O- U" d7 {: H s% M document.sform1.password.focus();
/ R; W& G+ v% T8 J" K document.sform1.password1.focus(); b, Y5 G: N$ @* x5 D
return false;* x5 D) m; F2 ^" R
} 7 m1 ~5 ]7 a Y* v* G
if (document.sform1.email.value == "") 8 I" a, d* Z& H4 O, i6 K. Y
{ ; x0 {/ s9 ?" l L
alert("请输入您的E-MAIL地址");
$ y# I9 P9 v. E3 V# R document.sform1.email.focus(); & x* [4 p4 u: S
return false; * G% T. y" T* U3 \7 r4 S
} t& S, t- r% g* @' r6 k7 K) q0 l
" K4 e. M& J2 M email=document.sform1.email.value; 5 v! ~$ s3 b4 w K9 E# f
emailerr=0 1 X% m* _/ {- x5 i; ?
for (i=0; i<email.length; i++) ( @8 r T" u4 p0 J# w+ Y
{ 3 }4 Z$ X$ {; a. e" u
if ((email.charAt(i) == "@") & (email.length > 5))
; T$ }1 B+ e6 u# S! S {
' O! s. z# W2 B% v. y; V emailerr=emailerr+1 5 d) v& O1 ], a w
} / Y. b+ v. E% u; [ `) [
} 6 B- ]+ a0 f4 n) U. I3 M
if (emailerr != 1)
6 c1 N$ W/ d4 r { ' M( w1 N4 m7 \) a. `9 V
alert("请输入正确的E-MAIL地址");
3 z: w$ I, |9 B3 `$ G$ A. t4 T4 M! q1 u4 @ document.sform1.email.focus(); & w0 k$ a! ]2 p* x4 Y8 t6 o1 [
return false;
7 i. S, b; F( A+ F6 W. B& p } # `8 |' q5 e8 G3 Z
" L7 ^2 G0 z. ?1 W% B
if (document.sform1.checkask.value=="") $ L6 G( M& V# j2 ]. @
{
8 y' }( ^8 r4 M! c/ n! @: T alert("密码提示问题不能为空");
9 L; `; q3 m+ |6 \' { document.sform1.checkask.focus();
4 H0 G+ ?& f8 b1 }1 T return false; + R0 q. u0 D2 e1 g/ y+ U0 G# Y
}
8 f o( J: X ^6 O- F, U if (document.sform1.checkans.value=="") ' z! Z! K4 @7 W m9 S+ h
{ . K n; u! l" A0 N
alert("您的密码提示问题答案不能为空"); 2 ?' C8 g% g6 M# N8 m8 j
document.sform1.checkans.focus();
+ c5 Z5 ?3 a L, z3 v6 t$ U3 w return false;
: R7 _- Q4 v' m% E3 d; R3 F; h }5 N' ?) S& ]2 \
return true; * c- ]& @% @. |3 U) i3 |& w: h
' n: y a- M5 Z0 F% [4 u" H( _}
& x: S6 w% v- r</script> |
|