|
  
- UID
- 1
- 帖子
- 738
- 精华
- 28
- 积分
- 14423
- 金币
- 2497
- 威望
- 1647
- 贡献
- 1445
|
这个脚本对你可能有帮助:) f: x( y. h8 K6 L
<script language="javascript"> 6 E j6 Y+ U% c6 Q2 c5 M; l
function IsDigit(cCheck) 9 b1 J9 u, P4 T+ r: @( F/ d) R
{ $ ~4 M2 a" V4 D- ~1 p& W* E
return (('0'<=cCheck) && (cCheck<='9')); , {' x$ N( e& w7 i8 {
} ! u! j4 M: q" l$ o4 u) N9 E/ g6 @- {
8 A8 h7 m( T; p8 Z- y4 K
function IsAlpha(cCheck) 1 n2 ]) l* p. t; ^7 J2 Q0 ?
{
0 C1 Y& [1 m" M# V9 s return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
6 p- ?) q R: e$ T4 u5 c }
9 ?5 H1 \" x! K
4 z' U! c5 F8 ~- xfunction IsaNull(cCheck)
4 q3 q) l, R: {' s7 C( n7 L {
6 I+ M/ [1 |7 M8 A0 u return(cCheck != " ") , Z. n- w5 m' I
} 5 l: @ A% t& u6 I
( k7 z. @9 b p& ?
function checkform() ( [" y& Z- a- P( Y
{ 3 B6 `3 V/ H7 ]+ p) G- M
id = document.sform1.id.value; ) d3 U- d7 i4 I$ h) K4 K
if (id == "") # |" j/ K# p& f! A* G* _
{
0 T3 }$ L( n9 ^( U, s) D& W' D4 n6 O alert("请输入注册名"); * s* q* P7 W, ` O' f- s6 k
document.sform1.id.focus();
, s* Y% ]: G6 j: A9 z5 h return false;
: t& e3 u! |, q+ n5 _- f S. v. k }
3 a) m7 d7 _. B {0 f1 i ; A9 B& n7 S6 E$ s! B! J* P
for (nIndex=0; nIndex<id.length; nIndex++) 6 [) I8 X6 D! S7 @) m; ?- ~& h: u
{ 4 Z# F/ n* Z% y3 e, H
cCheck = id.charAt(nIndex); ; K3 v: r5 K( }% }6 Q
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
+ i* B$ T6 C; T h {
# f1 A9 i* n& C+ l9 X4 R; I) {6 x alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
) l: ^! G0 B, @ Z7 ]% Y2 ?4 { document.sform1.id.focus(); M7 M/ ^9 I: H1 O. F7 A
return false;
* r7 A+ x! U7 w8 i) n; G1 J }
4 B0 h0 g$ O# T7 o/ q }
" z7 ~: _5 {9 i n0 R* ] chineseid = document.sform1.chineseid.value;
7 x o y$ ]7 n# R! B; n if (chineseid == "") + x' [* G) z" s5 e
{ 3 X- f, z6 x* J) L0 h
alert("请输入中文昵称"); ( D7 A! `4 w* _6 s& w! s9 ~
document.sform1.chineseid.focus(); . X- J+ b" f+ O+ r4 S* ?6 |2 x1 h
return false;
9 V& u8 C, N) y, F* n } 0 W/ s5 W+ C6 o: e
password = document.sform1.password.value;
- h' h/ v. K5 ^" n4 k% P8 c% s if (password == "")
+ w+ H) q" K4 [+ V$ p { ' X2 s8 u7 c/ |: N; m
alert("请输入登陆密码");
1 e8 \' W- ~; j9 o6 C) h4 j document.sform1.password.focus(); 2 b' a7 \" \7 L0 ^
return false; * \9 K7 I0 b3 P$ l& H/ ^' ?. M1 a5 X
}
8 s' o0 x& s7 Z' T: p, _/ v- g password1 = document.sform1.password1.value;
1 h. L$ `* g* h: f: P0 m! N if (password>password1)
+ J2 R) _" ?, V$ s2 x4 D3 t {
( G. S e, d, _3 I- { alert("重复密码与登陆密码不相同");
+ Y9 Z% \2 F3 |! F0 P0 f9 F document.sform1.password.focus(); / ~9 G% T7 e4 W: o
document.sform1.password1.focus();
9 J" X7 D" {+ b* o6 i return false;
& h$ N, U% l% M2 I }
! `6 ^: V# k. }3 h/ f$ ^8 Bif (password<password1)
8 |" ^) M! Y+ t/ x& U {, J3 C$ A4 w; j5 B
alert("重复密码与登陆密码不相同");
3 P: z, r, Y4 W- K2 ^; S7 V document.sform1.password.focus();
" p/ p9 W+ E, w% B document.sform1.password1.focus(); # B, X0 D/ i7 f% g! K9 S
return false;
! p' ~0 [- v) X }
c7 x P# S. @2 W x8 v! z% O if (document.sform1.email.value == "")
8 m: |% j K& @! S4 n {
[/ K3 \8 G# S' e3 U alert("请输入您的E-MAIL地址"); 0 A5 c+ s* b8 g' V9 C
document.sform1.email.focus(); 7 M/ s+ f9 {( R) T" S% q. F% S$ ^
return false;
o# m$ b, g. c }
6 R3 i! c/ }) { P
& T" [) I/ S9 |% i. L. X email=document.sform1.email.value; 7 }$ {8 ^6 K; G {) e* T
emailerr=0
& M: q) |2 w; v9 o% j for (i=0; i<email.length; i++) 1 l: E2 K% \0 n* J9 C: P/ `
{ $ F* T: e0 f$ u! W9 B6 r
if ((email.charAt(i) == "@") & (email.length > 5)) ( V" H9 C0 |/ v5 o5 c) U* S( J
{ 8 n' n2 f5 z" y {
emailerr=emailerr+1
: E# |" p( f) \/ o } / R# Z2 Z, U' ]+ n5 U P
}
) y- u. W2 J( h# _ if (emailerr != 1)
$ n5 B% T0 a4 v0 v {
$ Q0 O3 z- ?% i1 o* y alert("请输入正确的E-MAIL地址");
5 B/ V4 k( }! O( J document.sform1.email.focus(); & f, L. y3 P$ s% f; [0 J
return false;
: M- A( w8 Q. I W& r" i9 N: [, r }
0 `6 W6 `0 X3 r8 I- y4 [5 l
! U4 s8 y- i8 P, q, V if (document.sform1.checkask.value=="") : v5 q- b9 A9 M! N% \! `% y
{ 7 E9 i" G- C" {( b, k; r- h; i
alert("密码提示问题不能为空");
+ c, X' L+ n U document.sform1.checkask.focus();
" B3 M5 |: O0 j$ K. C6 q1 i return false; # X/ d( m" S5 W
}
: T' O" V. W) b if (document.sform1.checkans.value=="") ( e8 l, x9 `7 S- f' s* t
{ / b* A6 T) P( i
alert("您的密码提示问题答案不能为空");
7 h6 H! T. S( c& W D document.sform1.checkans.focus();
3 q3 j: e; P0 A return false;
; d3 V6 w# J7 ?+ v: o) Z3 C$ A }% u5 E# `7 U( l9 }7 p) { J( L) y
return true;
0 e7 ?2 [; n U - r: o& g, ?3 Y- J- Y. v
} # G; H' E+ G- Y/ n5 W) l% ]
</script> |
|