|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14417
- 金币
- 2494
- 威望
- 1647
- 贡献
- 1442
|
这个脚本对你可能有帮助:- |, m6 l' H$ u5 `/ F% ~3 W
<script language="javascript"> 8 {8 z3 L- R. w
function IsDigit(cCheck) . j2 m( q) z. `5 @2 [8 o+ m
{ ! V* O/ V- U2 @6 r2 i1 q
return (('0'<=cCheck) && (cCheck<='9'));
3 q: @# k" |- `* T2 `. [9 b }
* A* ^6 ^6 k( g. [ " T: R z* }# T0 Y4 b5 X H/ c6 O
function IsAlpha(cCheck)
7 E* T5 b: h' o0 o5 }3 O {
+ x% I) i" \, F/ s6 V return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
^2 S ^8 l7 T& ^ }
* t( c, L5 Z& P & g3 m4 T. x. |/ z8 I4 i7 O
function IsaNull(cCheck) 5 i$ U% Z) d/ r
{
# t. H$ [) F) _' w return(cCheck != " ") 1 g6 j" U; X8 y& u' V2 V6 V& l
} - D: O3 ]% x; H3 z0 z
6 Z% B8 F' Y+ V6 F& E8 o8 Ffunction checkform() 3 P2 u; u2 ]5 l# S. a
{ . a' X- W1 T5 `5 r/ I
id = document.sform1.id.value;
. q) `& I" p3 N% G( H if (id == "")
! |+ U* t8 z# a2 g {
7 C8 G$ b) Z$ f6 V( x3 R alert("请输入注册名");
/ r+ k. k5 U8 h( S8 P) b document.sform1.id.focus();
. w. D/ I4 t! g# B3 U6 r return false; 4 w2 n) Z4 y! R2 J' B9 l. I& m
}
$ }1 s- U" L2 V# T% W" Y( U8 ^
9 z2 e0 W" |3 c, ?3 c* W4 M for (nIndex=0; nIndex<id.length; nIndex++) 3 f3 u% g: V4 _! F, a
{
; n i$ T) i* t& F K cCheck = id.charAt(nIndex);
* u* n6 b H l0 y. u# L) n; x if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.')) 3 A1 I, p6 n2 m% a$ y+ T" R1 [
{
4 C# P' b- t. m( O V alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
4 o$ Q0 g$ y! ~* k I/ U! j document.sform1.id.focus(); 7 m' c: v: ?$ o- S& l! B
return false;
' c; Y- L$ L* |7 I3 Q, F5 |7 N }
- K, E6 E1 p E" Y } 8 B. i7 S; M T
chineseid = document.sform1.chineseid.value;
" h4 s/ w! g8 p if (chineseid == "") 0 b* s7 e" {& F4 X/ Z, _6 _
{ 0 C/ C$ o: J7 M2 t: x# ~% q
alert("请输入中文昵称"); 1 O& v" v* G: }9 v4 k
document.sform1.chineseid.focus();
% U. W1 t' C- X; C1 ^- k% [ return false; / S/ n" {( p \4 P
}
: p: n, M5 L1 e0 J7 T. [% B password = document.sform1.password.value; 4 r4 X9 G* @6 H( ^# ]' s
if (password == "")
9 Z/ {+ I) q! n3 l, K3 x p( d {
% g; C4 T: p I! G alert("请输入登陆密码");
& \1 V8 N7 t" U, m document.sform1.password.focus(); @; F- K5 F% M+ f( @6 ?/ J6 e
return false; ' M* j p& z8 x4 H
}
; m# |4 y3 w6 j$ Y- H& x password1 = document.sform1.password1.value;
* P: _4 y0 q$ Q if (password>password1)
; u2 h D- L1 C: S$ }; | {
+ \! l7 r1 C# z2 ^" j% g' _ alert("重复密码与登陆密码不相同"); 7 z2 ~! w: \% w3 [* @, ^
document.sform1.password.focus();
3 B" W% K& @$ i) D6 H document.sform1.password1.focus();
4 }) m9 K- y' ?0 n& f' |" l5 u return false;
; Y6 D' m3 D- H" l }
" X+ y0 Q2 H4 U ^if (password<password1)
# n9 D" y3 Z4 i& e0 M" q {
% {' B* K! V$ J9 a0 Q. y alert("重复密码与登陆密码不相同");
7 M3 w0 z5 ]: g0 \. t W document.sform1.password.focus();
: k% ~! b; s' l- p document.sform1.password1.focus();
$ I5 E! Y* Q/ F. `# @* j return false;
2 E3 K7 b" ~! Q- P } / P/ q" ?9 t0 U' X' X1 o5 i$ |
if (document.sform1.email.value == "")
! D, U0 P4 y9 p$ j) n" e1 T {
( D9 i% i) j' ]0 X alert("请输入您的E-MAIL地址");
- E5 V* _6 v: M% m document.sform1.email.focus();
5 H2 t1 [% b* G% [: T return false;
9 d. M- `# s' a# M } P/ k2 R. U; i# j1 s, I3 Z' }8 K
3 H6 C; H2 b( [. r0 B2 f, M email=document.sform1.email.value; + D% a3 W, C. J+ M9 A! L! f
emailerr=0 1 g) U& A* U8 c
for (i=0; i<email.length; i++)
* W D9 R$ G& @% } {
3 Q: C) h4 k9 s if ((email.charAt(i) == "@") & (email.length > 5)) 1 u9 D2 P. e9 F# P
{
! r0 m1 {- G) ~ _3 h6 w# N; ], {, H emailerr=emailerr+1
1 `) `2 t7 W3 ?. j" H+ a }
" e B `- ~$ { }
' v, b: N. W ], F( F( n o. l2 @ if (emailerr != 1) ' L9 X+ u$ Y2 H- d( f
{
& [' C" t( f( A/ u7 a alert("请输入正确的E-MAIL地址");
. r# j0 e7 r8 U1 n8 \ document.sform1.email.focus(); % n, X$ d) O+ X6 d4 t* ^2 ^
return false; * e# S2 C# Y$ n- T- g8 q
}
$ U) M9 g3 U3 i, s1 U+ G# O ( f2 N6 G# u0 ] g6 C# D
if (document.sform1.checkask.value=="")
K* o0 x* E4 r; r {
5 Y! e/ U! T! A, Q8 a4 Y alert("密码提示问题不能为空");
/ D7 A j6 }! l: k M document.sform1.checkask.focus();
6 f! d9 C' H! c/ ?9 Z: s, y return false;
9 N. Q5 X( \: F# _ }
; }1 P% ]; A+ m# M, W+ b if (document.sform1.checkans.value=="")
$ S* J$ ^/ a+ e0 ? { ; s7 }1 T, R2 O" i! O
alert("您的密码提示问题答案不能为空");
1 K0 G8 X$ l" s+ {/ G3 h1 v document.sform1.checkans.focus();
3 G- C; I5 |0 e( t return false;
+ z- Y5 U S- i4 B; j }! x$ u: d9 S( N; p) f) C; ?9 t
return true; \' }/ W* @0 b3 [" w: i4 j7 ^% x
1 }1 J8 x5 {% W7 o& b r} . N% M7 b4 U6 ]0 h
</script> |
|