2013年11月3日 星期日

Homework 10-28-2013

異地求學的莘莘學子
每逢佳節倍思親
遙望著天際
想著遠在家鄉的親人


                                                                                    宿舍外 夜景

在一切皆隱沒的寂靜的秋、在葉落後、在澄天底下、在殘花之上
心靈因此而不在寒涼,因此就滿足,什麼也都擁有了。


秋冬總會過去,暖春總會到來。

                                                                                   宿舍外  清晨


2013年10月28日 星期一

Lab 18 Google Maps


程式碼


輸入座標



跳到Google Map



 錯誤輸入

Lab 17 Regular Expression II

撰寫一個網頁能夠自動檢查輸入的字串是否為"整數或小數,逗號,整數或小數"格式(例如 24.9586,121.24114)



程式


正確輸入


錯誤輸入

錯誤輸入

<html>
<head>
</head>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
<input type="text" id="examplePass"/>
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit = function(){
var passwordRegex =/-?\d+(\.\d+)?\,\-?\d+(\.\d+)?$/;
if(!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify = document.getElementById("notify");



if(notify === null){
notify = document.createElement("p");
notify.textContent = "wrong input";
notify.id ="notify";
var body =document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>

Lab 16 Regular expression I

撰寫一個網頁能夠自動檢查輸入的字串是否為整數或小數(例如 12.34, -1.2, +0.02, .30)


程式碼


輸入正整數

輸入負的小數 

輸入英文