請輸入密碼:
JavaScript
<script type="text/javascript">
function show(){
var pass = $('#pass').val();
var encodedStr = '%e6%96%87%e7%ab%a0%e5%85%a7%e5%ae%b9' //文章內容轉為Url encode
if(pass == "password"){
$('#word')[0].innerHTML = decodeURI(encodedStr); //Url decode
$('#word').show();
}else{
alert('密碼錯誤');
$('#pass').val('');
}
}
</script>
function show(){
var pass = $('#pass').val();
var encodedStr = '%e6%96%87%e7%ab%a0%e5%85%a7%e5%ae%b9' //文章內容轉為Url encode
if(pass == "password"){
$('#word')[0].innerHTML = decodeURI(encodedStr); //Url decode
$('#word').show();
}else{
alert('密碼錯誤');
$('#pass').val('');
}
}
</script>
HTML
<p>請輸入密碼: <input id="pass" size="10" type="password" value="" /> <input id="btnReg" onclick="show()" type="button" value="顯示" /></p>
<div id="word" style="DISPLAY: none"> </div>