<scrip>
function checkacc(user){
<?php
do{
?>
if(user == '<?php echo $row_myusers["user_name"]; ?>'){
document.target.user_name.value = '帳號重複!';
document.target.user_name.style.color = '#FF0000';
return false;
}
<?php
} while($row_myusers = mysql_fetch_assoc($myusers));
?>
}
</scrip>
<input type="text" name="user_name" id="user_name" class="text03" onfocus="this.style.color = '#000000'" onblur="checkacc(this.value);" />
<input name="send1" type="submit" id="send1" onclick="if(document.target.user_name.value == '帳號重複!'){alert('*請輸入使用者帳號');return false;}"value="送出" />
2013年9月28日 星期六
2013年9月26日 星期四
javascript 彈出視窗confirm( ) ? web2 : web1
<?php
if((isset($_POST["MM_del"])) && ($_POST["MM_del"] == "false")) { //如果確認視窗為false(取消)
header("Location: 現在網址web1");
}
?>
<form method="POST" name="form2" id="form2" action="">
<input type="submit" name="del_que" id="del_que" value="刪除" onClick="if(!confirm('Are you sure?')){document.form2.MM_del.value='false';}" />
<input type="hidden" name="myid" id="myid" value="1" />
<input type="hidden" name="MM_del" value="form2">
</form>
參考資料:
http://taiwantc.com/js/js_tut_b_window0.htm
http://easonyo.pixnet.net/blog/post/25035463-javascript-%E5%BD%88%E5%87%BA%E5%B0%8F%E8%A6%96%E7%AA%97
http://blog.xuite.net/lqru17/blog/26134841-%E5%AD%90%E8%A6%96%E7%AA%97%E5%82%B3%E5%80%BC%E7%B5%A6%E6%AF%8D%E8%A6%96%E7%AA%97%E5%BE%8C%E5%AD%90%E8%A6%96%E7%AA%97%E9%97%9C%E9%96%89
if((isset($_POST["MM_del"])) && ($_POST["MM_del"] == "false")) { //如果確認視窗為false(取消)
header("Location: 現在網址web1");
}
?>
<form method="POST" name="form2" id="form2" action="">
<input type="submit" name="del_que" id="del_que" value="刪除" onClick="if(!confirm('Are you sure?')){document.form2.MM_del.value='false';}" />
<input type="hidden" name="myid" id="myid" value="1" />
<input type="hidden" name="MM_del" value="form2">
</form>
參考資料:
http://taiwantc.com/js/js_tut_b_window0.htm
http://easonyo.pixnet.net/blog/post/25035463-javascript-%E5%BD%88%E5%87%BA%E5%B0%8F%E8%A6%96%E7%AA%97
http://blog.xuite.net/lqru17/blog/26134841-%E5%AD%90%E8%A6%96%E7%AA%97%E5%82%B3%E5%80%BC%E7%B5%A6%E6%AF%8D%E8%A6%96%E7%AA%97%E5%BE%8C%E5%AD%90%E8%A6%96%E7%AA%97%E9%97%9C%E9%96%89
2013年9月23日 星期一
PHP+javascript 動態時間 setInterval( )
setInterval("document.getElementById('mytime').innerText=GetTime().toString()",1000);
參考資料:
setInterval( )
http://blog.darkthread.net/post-2011-12-13-js-getyear-in-ie.aspx
getFullYear()
http://www.seocn.info:999/import/description_4814_Detailed.html
2013年9月15日 星期日
2013年9月4日 星期三
HTML text 輸入限制
限輸入數字
<input type="text" onKeyUp="this.value=this.value.replace(/\D/g,'')" />
this.value=this.value.replace(/[^0-9]/g,'')
.replace(/[^\d]/g,'')
允許數字及 . (點)
this.value=this.value.replace(/[^0-9.]/g,'')
[時間格式 Y-m-d H:i:s ] 允許數字及 : (冒號) 及 - (減號)
this.value=this.value.replace(/[^\d\s:-]/g,'')
this.value.replace(/[^\d&:&-]/g,'')
[電話格式 ]
this.value=this.value.replace(/[^\d&-]/g,'')
允許中文
<input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
<input type="text" style="ime-mode:disabled">
清空文字
onfocus="if(this.value == '請輸入關鍵字'){ this.value=''; };"
去空白
onblur="this.value=this.value.trim();"
ps. PHP trim( String );
str_replace(" ", "", String); //去除(取代)全型空白
參考資料
http://blog.kkbruce.net/2012/02/javascript-regular-expression.html#.Um8YaBBi1Mc
http://blog.sina.com.cn/s/blog_9d37865901016ch3.html
http://blog.fend.cn/archives/54.html
http://blog.xuite.net/zong36/home/63327602-PHP-%E6%AD%A3%E5%89%87%E8%A1%A8%E7%A4%BA%E6%B3%95%28%E6%AD%A3%E8%A6%8F%E8%A1%A8%E7%A4%BA%E6%B3%95%29
http://www.webpage.idv.tw/maillist/maillist4/pro/05/regular1.htm 正規表示法圖說
http://www.eion.com.tw/Blogger/?Pid=1047
http://calos-tw.blogspot.tw/2007/12/javascript.html
<input type="text" onKeyUp="this.value=this.value.replace(/\D/g,'')" />
this.value=this.value.replace(/[^0-9]/g,'')
.replace(/[^\d]/g,'')
允許數字及 . (點)
this.value=this.value.replace(/[^0-9.]/g,'')
[時間格式 Y-m-d H:i:s ] 允許數字及 : (冒號) 及 - (減號)
this.value=this.value.replace(/[^\d\s:-]/g,'')
[電話格式 ]
this.value=this.value.replace(/[^\d&-]/g,'')
允許中文
<input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
<input type="text" style="ime-mode:disabled">
清空文字
onfocus="if(this.value == '請輸入關鍵字'){ this.value=''; };"
去空白
onblur="this.value=this.value.trim();"
ps. PHP trim( String );
str_replace(" ", "", String); //去除(取代)全型空白
參考資料
http://blog.kkbruce.net/2012/02/javascript-regular-expression.html#.Um8YaBBi1Mc
http://blog.sina.com.cn/s/blog_9d37865901016ch3.html
http://blog.fend.cn/archives/54.html
http://blog.xuite.net/zong36/home/63327602-PHP-%E6%AD%A3%E5%89%87%E8%A1%A8%E7%A4%BA%E6%B3%95%28%E6%AD%A3%E8%A6%8F%E8%A1%A8%E7%A4%BA%E6%B3%95%29
http://www.webpage.idv.tw/maillist/maillist4/pro/05/regular1.htm 正規表示法圖說
http://www.eion.com.tw/Blogger/?Pid=1047
http://calos-tw.blogspot.tw/2007/12/javascript.html
CSS 兩張圖重疊
<style type="text/css">
<!--
#IMG_1{
position:absolute;
top:10px;
left:10px;
width:150px;
height:150px;
background-color:#53E355;
z-index:1;
}
#IMG_2{
position:absolute;
top:30px;
left:30px;
width:150px;
height:150px;
background-color:#6DA9E7;
z-index:2;
}
-->
</style>
<img scr="IMG_1" id="IMG_1">
<img scr="IMG_2" id="IMG_2">
參考資料:
http://www.wibibi.com/info.php?tid=312
2013年9月3日 星期二
lighbox光箱效果
- <script src="js/jquery-1.10.2.min.js"></script> <script src="js/lightbox-2.6.min.js"></script>
- <link href="css/lightbox.css" rel="stylesheet" />
- 一群組 <a href="img/image-2.jpg" data-lightbox="roadtrip">image #2</a> <a href="img/image-3.jpg" data-lightbox="roadtrip">image #3</a> <a href="img/image-4.jpg" data-lightbox="roadtrip">image #4</a>
<a href="img/image-1.jpg" data-lightbox="image-1" title="My caption">image #1</a>
參考資料:
http://lokeshdhakar.com/projects/lightbox2/
http://prog-octopus.blogspot.tw/2009/01/lightbox2.html
訂閱:
文章 (Atom)