html form 案例

9 篇文章 0 订阅

--email.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>使用email</title>
<link href="email.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="frmTmp">
 <fieldset>
   <legend>请输入合法的邮件地址:</legend>
   <input name="txtEmail" type="email" 
          class="inputtxt" multiple="true">
   <input name="frmSubmit" type="submit" 
          class="inputbtn" value="提交">
 </fieldset>
</form>
</body>
</html>

emial.css

@charset "utf-8";
/* CSS Document */
body {
	font-size:12px
}
.inputbtn {
	border:solid 1px #ccc;
	background-color:#eee;
	line-height:18px;
	font-size:12px
}
.inputtxt {
	border:solid 1px #ccc;
	padding:3px;
	line-height:18px;
	font-size:12px;
	width:160px
}
fieldset{
	padding:10px;
	width:280px;
	float:left
}
/* 实例4增加样式 */
#spnColor{
	width:150px;
	float:left
}
#spnPrev{
	width:100px;
	height:70px;
	border:solid 1px #ccc;
	float:right
}
#pColor{
	font-weight:bold; 
	clear:both;
	text-align:center
}
p{
	clear:both;
	padding:0px;
                   margin:8px;
}
.p_center{
	text-align:center
}
.p_color{
	color:#666
}



--url .html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>使用url类型</title>
<link href="url.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="frmTmp">
 <fieldset>
   <legend>请输入网址:</legend>
   <input name="txtUrl" type="url" 
          class="inputtxt" />
   <input name="frmSubmit" type="submit" 
          class="inputbtn" value="提交" />
 </fieldset>
</form>
</body>
</html>




--born.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>使用number类型</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="frmTmp">
 <fieldset>
   <legend>输入您的出生时间:</legend>
   <input name="txtYear" type="number"
          class="inputtxt" min="1960" max="1990" 
          step="1" value="1990" />年
   <input name="txtMonth" type="number"
          class="inputtxt" min="1" max="12" 
          step="1" value="4"/>月
   <input name="txtDay" type="number"
          class="inputtxt" min="1" max="31" 
          step="1" value="23"/>日
   <input name="frmSubmit" type="submit" 
          class="inputbtn" value="提交" />
 </fieldset>
</form>
</body>
</html>



--time.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>选择日期</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="frmTmp">
 <fieldset>
   <legend>日期+时间类型:</legend>
   <input name="txtDate_1" type="date"
          class="inputtxt">
   <input name="txtDate_2" type="time"
          class="inputtxt">
   </fieldset>
   <fieldset>
   <legend>月份+星期类型:</legend>
   <input name="txtDate_3" type="month"
          class="inputtxt">
   <input name="txtDate_4" type="week"
          class="inputtxt">
   </fieldset>
   <fieldset>
   <legend>日期+时间型:</legend>
   <input name="txtDate_5" type="datetime"
          class="inputtxt">
   <input name="txtDate_6" type="datetime-local"
          class="inputtxt">
 </fieldset>
</form>
</body>
</html>


--required.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>使用input元素</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="frmTmp">
 <fieldset>
   <legend>属性required</legend>
   姓名:
   <input name="txtUserName" type="text" 
          class="inputtxt" required />
   <input name="frmSubmit" type="submit" 
          class="inputbtn" value="提交" />
 </fieldset>
</form>
</body>
</html>


--form.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>使用placeholder属性</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="123.asp" method="get" autocomplete="on">
姓:<input type="text" name="fname" /><br />
名: <input type="text" name="lname" /><br />
E-mail: <input type="email" name="email" autocomplete="off" /><br />
<input type="submit" />
</form>

<p>请填写并提交此表单,然后重载页面,来查看自动完成功能是如何工作的。</p>
<p>请注意,表单的自动完成功能是打开的,而 E-mail 域是关闭的。</p>
</body>
</html>


--file.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>

<form action="demo_form.asp" method="get">
Select images: <br/>
<input type="file" name="img" multiple="multiple" /><br/>
<input type="submit" />
</form>

<p>当您浏览文件时,请试着选择多个文件。</p>

</body>
</html>




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HTML表单是网页中常用的一种交互元素,用于收集用户的输入数据并提交给服务器进行处理。下面以一个注册表单为例来说明HTML表单的提交过程。 一个简单的注册表单通常包括用户输入用户名、密码和确认密码等字段,并且有一个提交按钮。用户填写完表单后,点击提交按钮,就会触发表单的提交事件。 HTML表单的代码如下: ``` <form action="register.php" method="POST"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required><br> <label for="password">密码:</label> <input type="password" id="password" name="password" required><br> <label for="confirm_password">确认密码:</label> <input type="password" id="confirm_password" name="confirm_password" required><br> <input type="submit" value="注册"> </form> ``` 上述代码中,`<form>`标签定义了一个表单,`action`属性指定了提交数据的目标地址,`method`属性指定了数据提交的方式。 用户填写表单后,点击提交按钮,表单数据将会被封装成一个HTTP请求,并发送给`register.php`文件。`register.php`文件是一个服务器端脚本,用于接收和处理表单数据。 `register.php`文件的代码如下: ```php <?php $username = $_POST['username']; $password = $_POST['password']; $confirm_password = $_POST['confirm_password']; // 进行数据验证和处理 // ... // 返回处理结果给用户 // ... ?> ``` `register.php`文件通过`$_POST`变量获取到表单提交的数据,并进行必要的验证和处理。在实际应用中,我们可以根据具体的需求来处理表单数据,比如将数据存储到数据库中,发送邮件通知等。 最后,`register.php`文件可以向用户返回处理结果,比如显示注册成功或失败的消息。你可以使用`echo`函数输出HTML代码来展示页面。 以上就是一个简单的HTML表单提交案例,它展示了HTML表单的基本使用和数据提交的过程。实际应用中,我们可以根据具体的业务需求来定制表单,并在服务器端对用户提交的数据进行处理。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值