https://docs.google.com/document/d/19_JGfN894KBJ_hbJ78IN-qIKHrfNWGQJdKadNfTJndk/edit?usp=sharing
2013年11月4日 星期一
Lab 21 Google Docs
URL
https://docs.google.com/document/d/19_JGfN894KBJ_hbJ78IN-qIKHrfNWGQJdKadNfTJndk/edit?usp=sharing
https://docs.google.com/document/d/19_JGfN894KBJ_hbJ78IN-qIKHrfNWGQJdKadNfTJndk/edit?usp=sharing
2013年11月3日 星期日
2013年10月28日 星期一
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>
訂閱:
文章 (Atom)


