<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script>

<style>

 input:focus,textarea:focus{

    border:1px solid #f00;

    background:#fcc;

 }

 .focus{

    border:1px solid #f00;

    background:#fcc;

 }

</style>

<script>

  $(function(){

     $(":input").focus(function(){

      $(this).addClass("focus");

     }).blur(function(){

       $(this).removeClass("focus");

     });

    });

</script>

</head>

<body>

<form action="#" method="post" id="regForm">

  <fieldset>

    <legend>个人基本信息</legend>

    <div>

     <label for="username">名称:</label>

     <input id="username" type="text" />

    </div>

    <div>

     <label for="pass">密码:</label>

     <input type="password" id="pass" />

    </div>

    <div>

     <label for="msg">详细信息:</label>

     <textarea id="msg"></textarea>

    </div>

  </fieldset>

</form>

</body>

</html>