< ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns= "http://www.w3.org/1999/xhtml" >
< head>
< meta http- equiv= "Content-Type" content= "text/html; charset=gb2312" / >
< title> 表单验证< / title>
< script type= "text/javascript" src= "js/jquery-1.11.1.min.js" > < / script>
< script type= "text/javascript" >
$ ( function ( ) {
$ ( "form :input.required" ) . each ( function ( ) {
var $required = $ ( "<strong class='star'>*</strong>" ) ;
$ ( this ) . parent ( ) . append ( $required) ;
} )
$ ( "form :input" ) . blur ( function ( ) {
if ( $ ( this ) . is ( "#username" ) ) {
if ( $ ( this ) . val ( ) == "" ) {
alert ( "用户名不能为空!" ) ;
}
}
if ( $ ( this ) . is ( "#pwd" ) ) {
if ( $ ( this ) . val ( ) == "" ) {
alert ( "密码不能为空!" ) ;
}
if ( this . value. length < 8 ) {
alert ( "密码不能小于8位,请重新输入!" ) ;
}
}
} )
} )
< / script>
< / head>
< body>
< form>
< h3 align= "center" > 用户注册< / h3>
< div class = "dt" > 用户名:< input type= "text" id= "username" name= "username" size= 20 class = "required" / > < / div>
< div class = "dt" > 密& nbsp; & nbsp; 码:< input type= "password" id= "pwd" name= "pwd" size= 20 class = "required" / > < / div>
< div class = "dt" > 性& nbsp; & nbsp; 别:< input type= "text" id= "sex" name= "sex" size= 4 maxlength= 3 / > < / div>
< div class = "dt" > 年& nbsp; & nbsp; 龄:< input type= "text" id= "age" name= "age" size= 4 maxlength= 3 / > < / div>
< div class = "dt" >
< input type= "submit" name= "sub" value= "注册" / >
< / div>
< / form>
< / body>
< / html>
< html>
< head>
< meta http- equiv= "Content-Type" content= "text/html; charset=gb2312" / >
< title> 表格隔行换色< / title>
< style>
. a{
background: lightblue;
}
. b{
background: yellow;
}
< / style>
< script type= "text/javascript" src= "js/jquery-1.11.1.min.js" > < / script>
< script type= "text/javascript" >
$ ( function ( ) {
$ ( "tbody>tr:odd" ) . addClass ( "a" ) ;
$ ( "tbody>tr:even" ) . addClass ( "b" ) ;
} )
< / script>
< / head>
< body>
< table border= "1" align= "center" >
< caption> JavaScript开发非常之旅套系图书< / caption>
< thead bgcolor= "#B2B2B2" align= "center" valign= "bottom" >
< tr>
< th> 书名< / th>
< th> 出版单位< / th>
< / tr>
< / thead>
< tbody>
< tr>
< td width= "185" > JavaScript从入门到精通< / td>
< td width= "220" > 吉林省明日科技有限公司< / td>
< / tr>
< tr>
< td> JavaScript自学视频教程< / td>
< td> 吉林省明日科技有限公司< / td>
< / tr>
< tr>
< td> JavaScript程序设计< / td>
< td> 吉林省明日科技有限公司< / td>
< / tr>
< tr>
< td> jQuery开发基础教程< / td>
< td> 吉林省明日科技有限公司< / td>
< / tr>
< tr>
< td> jQuery从入门到精通< / td>
< td> 吉林省明日科技有限公司< / td>
< / tr>
< / tbody>
< / table>
< / body>
< / html>
1 `` `