助教悲劇補充:現在依然無法判斷大小
<html>
<title>lab14</title>
<body>
<form action="http://maps.google.com/maps" method="get" name="f" onsubmit="return check()">
<input name="q" type="text" /><br />
<input name="send" type="submit" value="search" />
</form>
</body>
<script>
var floatReg =/^([+-]?)[1-9]\d*(\.\d*)?,([+-]?)[1-9]\d*(\.\d*)?$/;
//funtion外宣告可以全域使用
var str=",";
f1=f.q.value.indexOf(str);
f2=f.q.value.length;
latitude=f.q.value.substring(0,f1);
longitude=f.q.value.substring(f1+1,f2);
y=parseInt(latitude);
x=parseInt(longitude);
//alert(y);
//alert(x);
//alert(y>90);
//alert(x<180);
//alert(y>90||x>180);
function check(){
if(!floatReg.test(f.q.value)){
alert("It's not correct format");
f.q.value="";
document.f.q.focus();
return false;
}
}
document.write(Date());
</script>
</html>
2013年10月24日 星期四
2013年10月21日 星期一
2013年10月14日 星期一
102-1_Lab12 Change an image by moving the mouse
<img src ="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMLHfEEgNYDFrU9Ula0Uka8uKzfQgrzcLfZ9cvNWySdYK2ia7FN2UXXYnpJd1lb6hgGWPWT5QOmPZb0law4NjhqizXa8RASzX7AvoTXmN7dh8PuU4rh9G_RfrO1wQiTpfnTWtUebm4Gdo/s320/DSC_1795.JPG" onmouseover="mOver(this)" onmouseout="mOut(this)" >
<script>
function mOver(obj)
{
obj.setAttribute("src","https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjuKSUhjEjG0IXijdpJdTBhemp4LkzjB80Mj6JZaJFbfjbZxepAcD9vN_ShNEdiJ8Mg_aaGiiCTzURbWhUeJKiMRL4uae0ilXuff7GuCuv4z8-o5fjEQGztZTCNORtMqeOY6q9YyNgpJl8/s320/DSC_1772.JPG");
}
function mOut(obj)
{
obj.setAttribute("src","https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMLHfEEgNYDFrU9Ula0Uka8uKzfQgrzcLfZ9cvNWySdYK2ia7FN2UXXYnpJd1lb6hgGWPWT5QOmPZb0law4NjhqizXa8RASzX7AvoTXmN7dh8PuU4rh9G_RfrO1wQiTpfnTWtUebm4Gdo/s320/DSC_1795.JPG");
}
</script>
主要為切換兩個事件
mouseover & mouseout
mouseover & mouseout
2013年10月7日 星期一
102-1_Lab7,9:Using browsers for programming
原程式碼:
<html>
<head>
</head>
<Title>Password Regex</Title>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
Password:<input type="password" id="examplePass" name="Enter password" />
<input type="submit" />
</form>
</body>
<script language="javascript">
document.getElementById("exampleForm").onsubmit = function(){
var passwordRegex = /^[A-Za-z\d]{6,}$/;
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 = "Passwords need to above 6 words!";
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
Sol of lab7 condition:/^[A-Za-z\d]{6,}$/
(至少要一大寫英或小寫英或數字、超過6字)
Sol of lab9 condition:/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,}$/
(至少一數字、一小寫英、一大寫英、一特殊字元("_"底線除外)、超過6字)
Sol of lab9 condition:/^(?=.*\d)(?=.*[\W_]).{6,}$/
(至少一數字、一特殊字元、超過6字,大小寫英可有可無)
"\W"為不包含大小寫A-Z和0~9和"_"
"\w"則剛好和\W完全相反
所以取特殊字元必須使用大寫"\W"(此時底線除外)
最後把底線加入:"[\W_]"
第二版程式碼:
<html>
<head>
</head>
<TITLE>exam the password</TITLE>
<body id="body">
<form method="POST" action="form-handler.php" onsubmit="return checkForm(this);">
<p>Username: <input type="text" name="username"></p>
<p>Password: <input type="password" name="pwd1"></p>
<p>Confirm Password: <input type="password" name="pwd2"></p>
<p><input type="submit"></p>
</form>
</body>
<script type="text/javascript">
function checkPassword(str)
{
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,}$/;
// /^[A-Za-z\d]{6,}$/至少要一大寫英或小寫英或數字、超過6字
// /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,}$/ 至少一數字、一小寫英、一大寫英、一特殊字、超過6字
return re.test(str);
}
function checkForm(form)
{
if(form.username.value == "") {
alert("Error: Username cannot be blank!");
form.username.focus();
return false;
}
re = /^\w+$/;
if(!re.test(form.username.value)) {
alert("Error: Username must contain only letters, numbers and underscores!");
form.username.focus();
return false;
}
if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value) {
if(!checkPassword(form.pwd1.value)) {
alert("The password you have entered is not valid!");
form.pwd1.focus();
return false;
}
} else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}
return true;
}
</script>
</html>
參考資料:1、2、3、4、5、6
<html>
<head>
</head>
<Title>Password Regex</Title>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
Password:<input type="password" id="examplePass" name="Enter password" />
<input type="submit" />
</form>
</body>
<script language="javascript">
document.getElementById("exampleForm").onsubmit = function(){
var passwordRegex = /^[A-Za-z\d]{6,}$/;
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 = "Passwords need to above 6 words!";
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
Sol of lab7 condition:/^[A-Za-z\d]{6,}$/
(至少要一大寫英或小寫英或數字、超過6字)
Sol of lab9 condition:/^(?=.*\d)(?=.*[\W_]).{6,}$/
(至少一數字、一特殊字元、超過6字,大小寫英可有可無)
"\W"為不包含大小寫A-Z和0~9和"_"
"\w"則剛好和\W完全相反
所以取特殊字元必須使用大寫"\W"(此時底線除外)
最後把底線加入:"[\W_]"
第二版程式碼:
<html>
<head>
</head>
<TITLE>exam the password</TITLE>
<body id="body">
<form method="POST" action="form-handler.php" onsubmit="return checkForm(this);">
<p>Username: <input type="text" name="username"></p>
<p>Password: <input type="password" name="pwd1"></p>
<p>Confirm Password: <input type="password" name="pwd2"></p>
<p><input type="submit"></p>
</form>
</body>
<script type="text/javascript">
function checkPassword(str)
{
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,}$/;
// /^[A-Za-z\d]{6,}$/至少要一大寫英或小寫英或數字、超過6字
// /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{6,}$/ 至少一數字、一小寫英、一大寫英、一特殊字、超過6字
return re.test(str);
}
function checkForm(form)
{
if(form.username.value == "") {
alert("Error: Username cannot be blank!");
form.username.focus();
return false;
}
re = /^\w+$/;
if(!re.test(form.username.value)) {
alert("Error: Username must contain only letters, numbers and underscores!");
form.username.focus();
return false;
}
if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value) {
if(!checkPassword(form.pwd1.value)) {
alert("The password you have entered is not valid!");
form.pwd1.focus();
return false;
}
} else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}
return true;
}
</script>
</html>
參考資料:1、2、3、4、5、6
2013年10月1日 星期二
102-1_Lab 4:破解網路大學排名DIY
破解網路大學排名DIY
能見度方法因內容過舊而不適用
其原理為找尋該網站之反向連結
故提供兩個網站提供該項服務
MajesticSEO:
Opensiteexplorer:
in Page:choose page on this root domain
參考網站:SEO部落客
能見度方法因內容過舊而不適用
其原理為找尋該網站之反向連結
故提供兩個網站提供該項服務
MajesticSEO:
Opensiteexplorer:
in Page:choose page on this root domain
參考網站:SEO部落客
訂閱:
文章 (Atom)