本文最后更新于347天前,其中的信息可能已经过时,如有错误请在评论区悄悄告诉我~~~
PHP小日历
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>日历</title>
<style type="text/css">
h1,table{
display: flex;
justify-content: center;
align-items: center;
}
.tdb{
border: 1px solid #000;
}
td{
width: 50px;
height: 30px;
text-align: center;
}
table{
border: 1px solid #000;
width: 378px;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>
<?php
$now = date('Y年m月d日');
echo $now;
?>
</h1>
<table>
<tr>
<td>日</td>
<td>一</td>
<td>二</td>
<td>三</td>
<td>四</td>
<td>五</td>
<td>六</td>
</tr>
<?php
//获取当前时间
$year = date('y');
$month = date('m');
$day = date('d');
$firstday = date('w',strtotime($year.'-'.$month.'-1'));
// 获取月份天数
if ($year % 4 ==0 && $year % 100 !=0 || $year % 400 == 0){
$flag = 1;
}
else{
$flag = 0;
}
switch($month){
case 4:
case 6:
case 9:
case 11:
$days = 30;
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
$days = 31;
break;
case 2:
if ($flag == 1){
$days = 29;
}
else{
$days = 28;
}
break;
}
//循环输出日历
echo "<tr>";
for ($i=0;$i<$firstday;$i++){
echo '<td></td>';
}
for ($i=1;$i<=$days;$i++){
if (($i + $firstday - 1) % 7 == 0){
echo "</tr><tr>";
}
if ($i == $day){
echo "<td class='tdb'> $i </td>";
}
else{
echo "<td> $i </td>";
}
}
echo "</tr>";
?>
</table>
</body>
</html>
效果
HTML的个人介绍
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>个人介绍</h1>
<form accept="">
<table border="1">
<tr>
<td>姓名:</td>
<td><input type="text"></td>
<td>必须为6-20个字母</td>
</tr>
<tr>
<td>性别:</td>
<td>
<input type="radio">男
<input type="radio">女
</td>
<td></td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text"></td>
<td>取值为0-100</td>
</tr>
<tr>
<td>个人密码:</td>
<td><input type="password"></td>
<td>6-10个字符</td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password"></td>
<td>与个人密码相同</td>
</tr>
<tr>
<td>你的爱好:</td>
<td>
<input type="checkbox">打游戏
<input type="checkbox">吃饭
<input type="checkbox">睡觉
<input type="checkbox">刷短视频
<input type="checkbox">编程
</td>
<td></td>
</tr>
<tr>
<td>你最喜欢的颜色:</td>
<td>
<select>
<option>红色</option>
<option>绿色</option>
</select>
</td>
<td></td>
</tr>
<tr>
<td>个人介绍:</td>
<td><textarea></textarea></td>
<td>不能为空</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="提交">
<input type="reset" value="重置">
</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
效果
HTML的个人介绍(加js验证)
(随便写写,有错误还请多多见谅,也欢迎提出)
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>个人介绍</title>
</head>
<body>
<h1>个人介绍</h1>
<form accept="">
<table border="1">
<tr>
<td>姓名:</td>
<td><input type="text" id="username"></td>
<td id="username_text">必须为6-10个字符</td>
</tr>
<tr>
<td>性别:</td>
<td>
<label><input type="radio" name="age" checked>男</label>
<label><input type="radio" name="age">女</label>
</td>
<td></td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" id="age"></td>
<td id="age_text">取值为0-100</td>
</tr>
<tr>
<td>个人密码:</td>
<td><input type="password" id="pass"></td>
<td id="pass_text">必须为6-20个字符</td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password" id="password"></td>
<td id="password_text">与个人密码相同</td>
</tr>
<tr>
<td>你的爱好:</td>
<td>
<label><input type="checkbox" class="love">打游戏</label>
<label><input type="checkbox" class="love">吃饭</label>
<label><input type="checkbox" class="love">睡觉</label>
<label><input type="checkbox" class="love">刷短视频</label>
<label><input type="checkbox" class="love">编程</label>
</td>
<td id="love_text"></td>
</tr>
<tr>
<td>你最喜欢的颜色:</td>
<td>
<select id="colour">
<option value="0">未选择</option>
<option value="1">红色</option>
<option value="2">绿色</option>
</select>
</td>
<td id="colour_text"></td>
</tr>
<tr>
<td>个人介绍:</td>
<td><textarea id="introduce"></textarea></td>
<td id="introduce_text">不能为空</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="提交" id="submit">
<input type="reset" value="重置">
</td>
<td></td>
</tr>
</table>
</form>
<script>
//姓名验证
let username = document.getElementById("username");
let username_text = document.getElementById("username_text");
username.onblur = function() {
if (username.value.length > 5 && username.value.length < 21) {
username_text.innerText = " √"
}
else {
username_text.innerText = " × 必须为6-10个字符"
}
}
username.onclick = function() {
username_text.innerText = "必须为6-10个字符";
}
//年龄判断
let age = document.getElementById("age");
let age_text = document.getElementById("age_text");
age.onblur = function() {
if (!(/(^[0-9]\d*$)/.test(age.value)) && age.value != "") {
age_text.innerText = " × 必须为正整数"
}
else if (age.value > 0 && age.value < 101 && age.value != "") {
age_text.innerText = " √"
}
else {
age_text.innerText = " × 取值为0-100"
}
}
age.onclick = function() {
age_text.innerText = "取值为0-100";
}
//密码判断
let pass = document.getElementById("pass");
let password = document.getElementById("password");
let pass_text = document.getElementById("pass_text");
let password_text = document.getElementById("password_text");
pass.onblur = function() {
if (pass.value.length < 6 || pass.value.length > 20) {
pass_text.innerText = " × 必须为6-20个字符"
}
else {
pass_text.innerText = " √"
}
}
pass.onclick = function() {
pass_text.innerText = "必须为6-20个字符";
}
password.onblur = function() {
if (pass.value != password.value) {
password_text.innerText = " × 两次密码输入不一致";
}
else if (pass.value == password.value && password.value != "") {
password_text.innerText = " √";
}
}
password.onclick = function() {
password_text.innerText = "与个人密码相同";
}
//个人介绍判断
let introduce = document.getElementById("introduce");
let introduce_text = document.getElementById("introduce_text");
introduce.onblur = function() {
if (introduce.value == "") {
introduce_text.innerText = " × 不能为空";
}
else {
introduce_text.innerText = " √";
}
}
introduce.onclick = function() {
introduce_text.innerText = "不能为空";
}
//爱好选择判断
let love = document.getElementsByClassName("love");
let love_text = document.getElementById("love_text");
let love_L = 0;
for (let i = 0; i < love.length; i++) {
love[i].onclick = function() {
if (love[i].checked == true) {
love_L = love_L + 1;
}
else if (love[i].checked == false) {
love_L = love_L - 1;
}
if (love_L == 0) {
love_text.innerText = " × 至少选择一项";
}
else if (love_L != 0) {
love_text.innerText = "";
}
}
}
//颜色选择判断
let colour = document.getElementById("colour");
let colour_text = document.getElementById("colour_text");
colour.onclick = function() {
if (colour.selectedIndex == 0) {
colour_text.innerText = " × 请选择你喜欢的颜色";
}
else if (colour.selectedIndex != 0) {
colour_text.innerText = "";
}
}
</script>
</body>
</html>
未完成!!!
评论