dポイントプレゼントキャンペーン実施中!

ここまできました

いろいろなものを参考にしてこれがよいと判断しました
正しいユーザ名とパスワードを入力して(入力した文字がそのまま表示されないようにして両方ともただしければ「ログインに成功しました」どちらかでも間違っていたら「ログインに失敗しました」というjavascritptを作りたいのですがここまで来るのに参考にしたものなどが多すぎて、どこに書いていいのかわかりませんIDパスワードは guestです
どなたかご教授ください
実行できるようにお願いします


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html; charset=shift_jis">
<meta http-equiv="content-style-type" content="text/css">
<style type="text/css">
body,th,td {
font-size: 13px;
}
table.passwd {
margin-top: 80px;
width: 400px;
background: #00a2a2;
}
td.ttl {
padding: 10px;
color: #fff;
}
td.input {
padding: 10px;
background: #fff;
font-family: verdana,helvetica,arial,osaka;
width: 100%;
}
input.len {
width: 220px;
}
input.btn {
font-family: verdana,helvetica,arial,osaka;
width: 100px;
height: 32px;
}
</style>
<title>アクセス認証</title>
</head>
<body>
<div align="center">
<form action="!gate_cgi!" method="post">
<table cellspacing="1" class="passwd">
<tr>
<td class="ttl"><b>アクセス認証</b></td>
<tr></tr>
<td class="input">
USER ID :<br>
<input type="text" name="id" class="len"><br><br>

PASSWORD :<br>
<input type="password" name="pw" class="len"><br><br>

<div align="right">
<input type="submit" name="login" value="LOG IN" class="btn">
</div>
</td>
</tr>
</table>
</form>
</div>
<script language="javascript">
<!--
self.document.forms[0].id.focus();
//-->
</script>
</body>
</html>

A 回答 (2件)

どこまで、きたのかりかいできませんが、20ぽんとをくれたので。


しょうかいしたmd5をhttp://closure-compiler.appspot.com/homeであっしゅく。
ぜんかくくうはくは、はんかくに。
<!DOCTYPE html>
<html lang="ja">
<head>
 <title></title>
 <meta charset="utf-8">
</head>

<body>
<form onsubmit="check.call(this,event)">
<ul>
 <li>USER ID :<input type="text" name="id">
 <li>PASSWORD :<input type="password" name="pw">
 <li><input type="submit" value="LOG IN">
</ul>
</form>

<script>
var USER_LIST = {
 '1234': 'd81f9c1be2e08964bf9f24b15f0e4900', //345
 'guest' : '084e0343a0486ff05530df6c705c8bb4' //guest
}
var MD5_T=[0,3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461, 530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745],MD5_round1=[[0,7,1],[1,12,2],[2,17,3],[3,22,4],[4,7,5],[5,12,6],[6,17,7],[7,22,8],[8,7,9],[9,12,10],[10,17,11],[11,22,12],[12,7,13],[13,12,14],[14,17,15],[15,22,16]],MD5_round2=[[1,5,17],[6,9,18],[11,14,19],[0,20,20],[5,5,21],[10,9,22],[15,14,23],[4,20,24],[9,5,25],[14,9,26],[3,14,27],[8,20,28],[13,5,29], [2,9,30],[7,14,31],[12,20,32]],MD5_round3=[[5,4,33],[8,11,34],[11,16,35],[14,23,36],[1,4,37],[4,11,38],[7,16,39],[10,23,40],[13,4,41],[0,11,42],[3,16,43],[6,23,44],[9,4,45],[12,11,46],[15,16,47],[2,23,48]],MD5_round4=[[0,6,49],[7,10,50],[14,15,51],[5,21,52],[12,6,53],[3,10,54],[10,15,55],[1,21,56],[8,6,57],[15,10,58],[6,15,59],[13,21,60],[4,6,61],[11,10,62],[2,15,63],[9,21,64]];function MD5_F(a,b,d){return a&b|~a&d}function MD5_G(a,b,d){return a&d|b&~d}function MD5_H(a,b,d){return a^b^d} function MD5_I(a,b,d){return b^(a|~d)}var MD5_round=[[MD5_F,MD5_round1],[MD5_G,MD5_round2],[MD5_H,MD5_round3],[MD5_I,MD5_round4]];function MD5_pack(a){return String.fromCharCode(a&255)+String.fromCharCode(a>>>8&255)+String.fromCharCode(a>>>16&255)+String.fromCharCode(a>>>24&255)}function MD5_unpack(a){return a.charCodeAt(0)|a.charCodeAt(1)<<8|a.charCodeAt(2)<<16|a.charCodeAt(3)<<24}function MD5_number(a){for(;a<0;)a+=4294967296;for(;a>4294967295;)a-=4294967296;return a} function MD5_apply_round(a,b,d,e,g){var h,c,i,j,f;h=e[0];c=e[1];i=e[2];j=e[3];f=g[0];e=g[1];g=g[2];d=d(b[c],b[i],b[j]);a=b[h]+d+a[f]+MD5_T[g];a=MD5_number(a);a=a<<e|a>>>32-e;a+=b[c];b[h]=MD5_number(a)} function MD5_hash(a){var b,d,e,g,h,c,i,j,f,k,l;e=[1732584193,4023233417,2562383102,271733878];h=a.length;c=h&63;b=c<56?56-c:120-c;if(b>0){a+="\u0080";for(c=0;c<b-1;c++)a+="\0"}a+=MD5_pack(h*8);a+=MD5_pack(0);h+=b+8;b=[0,1,2,3];d=Array(16);g=Array(4);for(k=0;k<h;k+=64){c=0;for(f=k;c<16;c++,f+=4)d[c]=a.charCodeAt(f)|a.charCodeAt(f+1)<<8|a.charCodeAt(f+2)<<16|a.charCodeAt(f+3)<<24;for(c=0;c<4;c++)g[c]=e[c];for(c=0;c<4;c++){i=MD5_round[c][0];j=MD5_round[c][1];for(f=0;f<16;f++)MD5_apply_round(d,g,i,b, j[f]),l=b[0],b[0]=b[3],b[3]=b[2],b[2]=b[1],b[1]=l}for(c=0;c<4;c++)e[c]+=g[c],e[c]=MD5_number(e[c])}return MD5_pack(e[0])+MD5_pack(e[1])+MD5_pack(e[2])+MD5_pack(e[3])}function MD5_hexhash(a){var b,d,e;e=MD5_hash(a);b="";for(a=0;a<16;a++)d=e.charCodeAt(a),b+="0123456789abcdef".charAt(d>>4&15),b+="0123456789abcdef".charAt(d&15);return b};

function check (event) {
 var es = this.elements;
 var id = es['id'];
 var pw = es['pw'];
 var ps = USER_LIST[id.value];
 
 if (ps) {
  if (MD5_hexhash (pw.value) === ps) {
   return alert ("ログインに成功しました");
  }
  else {
   alert ("ログインに失敗しました");
  }
 }
 return true;
}
</script>
    • good
    • 0

成功したときに submit()、失敗した時には何もしない、って動作でいいんでしょうか。


#1 さんのコードに手を加えただけのものですが…。
http://jsfiddle.net/ZzQSP/1/

力不足で IE8- に対応できませんでした。適宜修正をお願いします。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!