PHP & JavaScript Room :: 設置サンプル

実行結果

Ajax Username Check - Using JQuery! | 設置サンプル

▼ユーザー名を入力しフォーカスを外すと、入力したユーザー名が存在するかを表示します。
※「john」または「martin」は存在するユーザーです。

ユーザー登録フォーム

Ajax Indicator

設置サンプルのソース

<!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" xml:lang="ja" lang="ja">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="ja" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="imagetoolbar" content="no" />
      <title>Ajax Username Check - Using JQuery! | 設置サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <!-- JS -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript">
         $(function() {
            $('#usernameLoading').hide();
            $('#username').blur(function(){
               $('#usernameLoading').show();
               $.post("include/ajax/jquery_plugin_forminput/check.php", {
                  username: $('#username').val()
                  }, function(response){
                  $('#usernameResult').fadeOut();
                     setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400);
                  });
                  return false;
               });
            });
            function finishAjax(id, response) {
               $('#usernameLoading').hide();
               $('#'+id).html(unescape(response));
               $('#'+id).fadeIn();
            }
      </script>
      <!-- CSS -->
      <link rel="stylesheet" type="text/css" href="/content/lib/jquery/jquery.jqpuzzle.css" />
   <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
   <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1><a href='http://www.shawngo.com/gafyd/index.html'>Ajax Username Check - Using JQuery!</a> | 設置サンプル</h1>
         <p>▼ユーザー名を入力しフォーカスを外すと、入力したユーザー名が存在するかを表示します。<br>※「john」または「martin」は存在するユーザーです。</p>
<!-- CODE -->
         <fieldset>
            <legend>ユーザー登録フォーム</legend>
            <form action="#" method="post" onsubmit="return false;">
               <p>
                  <label for="username">ユーザー名:</label> <input type="text" name="username" id="username" />
                  <span id="usernameLoading"><img src="/content/img/loading.gif" alt="Ajax Indicator" /></span>
                  <span id="usernameResult"></span>
               </p>
               <p><label for="password">パスワード:</label> <input type="password" name="password" id="password"/></p>
               <p><input type="submit" name="submit" value="Sign Up!" /></p>
            </form>
         </fieldset>
<!-- / CODE -->
      </div>
   </body>
</html>