js学習2
2729 ワード
<html>
<head>
<title> 2</title>
<script language="javascript">
<!--
function oneSubmit(oneForm) {
// for(var i = 0; i < oneForm.elements.length; i++) {
// if(oneForm.elements[i].value == "") {
// alert(" !!");
// return false;
// }
// }
// return true;
alert(oneForm.text1.value);
if(oneForm.text1.value.toUpperCase() == oneForm.text2.value.toUpperCase()) {
return true;
}
alert(" ");
return false;
}
function threeText(text) {
if(text.value != "") {
alert(" ");
}else {
alert(" ");
}
}
function fourText(text) {
if(text.value.indexOf("sheng") != -1) {
alert("sheng");
} else{
alert(" sheng");
}
}
function fiveText(text) {
var temp = text.value.substring(2, 4);
alert(temp);
}
function sixText(text) {
// var temp = Math.pow(parseInt(text.value), 2);
// var temp = Math.PI;
var temp = Math.round(parseFloat(text.value));
alert(temp);
}
function dataListener() {
var date = new Date();
// var temp = date.getYear();
// var temp = date.getTime();
var temp = date.getMonth();
alert(date);
}
-->
</script>
</head>
<body>
<form action="test.html" method="post" onSubmit="return oneSubmit(this)">
text1 <input type="text" name="text1"> </br>
text2 <input type="text" name="text2"> </br>
text3 <input type="text" name="text3" onChange="threeText(this)"> </br>
text2 <input type="text" name="text4" onChange="fourText(this)"> </br>
text5 <input type="text" name="text5" onChange="fiveText(this)"> </br>
text6 <input type="text" name="text6" onChange="sixText(this)"> </br>
<input type="submit" value=" "> </br>
<input type="button" value=" " onClick="dataListener()">
</form>
</body>
</html>