0314-form表单标签的使用

来源:互联网 发布:北京海量数据 干嘛的? 编辑:程序博客网 时间:2024/06/04 04:46
代码:
<form>
<!--明文text-->
请输入账户名<input type="text"><br><br>
<!--暗文输入password-->
请输入密码<input type="password"><br><br>
<!--设置按钮,若设置只能选一个,所有标签添加name属性且值一样,在后面加checked="checked"设置默认值,
只能设置一个,若设置了多个,最后一个checked有效-->
性别:<input type="radio"name="a">男
<input type="radio"name="a">女
<input type="radio"checked="checked"name="a">保密<br><br>
<!--设置复选框,也可设置默认,方法同上-->
性取向:<input type="checkbox">男
<input type="checkbox">女(可多选)<br><br>
爱好:<input type="checkbox">篮球
<input type="checkbox">足球
<input type="checkbox">羽毛球
<input type="checkbox">大保健(可多选)<br><br>
<!--还可以添加HTML5中的date的属性值来选择时间还有颜色,以及邮箱和电话号码等等,详情
http://www.w3school.com.cn/html5/html_5_form_input_types.asp-->
<label>请选择出生年月:<input type="date"></label><br><br>
<label>请输入邮箱:<input type="email"></label><br><br>
<label>请输入手机号:<input type="number"></label><br><br>
<label>请设置预留颜色:<input type="color"></label><br><br>
<!--按钮就是设置设置type的值是buttom,还可设置为reset用来重置已经输入的内容
信息用来提交到服务器,可设置为submit-->
<input type="button"align="center"value="注册"onclick="alert(250)">
<input type="reset">

<!--当然,可以使用图片作为按钮如下<input type="image" src="images/1.jpg">-->
</form>
想使用submit时,需要具备两个条件
1.需要给form表单添加一个action的属性,通过这个action属性指定需要提交到的服务器地址
<formaction="www.baidu.com"></form>
2.需要给需要提交到服务器的表单元素添加一个name属性
请输入账户名<input type="text"name="aa">
请输入密码<input type="password"name="bb">
其他标签:
可以给表单添加边框,格式:
<form>
<fieldset>
<legend>边框标题</legend>
</fieldset>
</form>
还可以给表单中添加多行输入框<textavea></textavea>,他有一些属性,例如限制行(cols)字数,满了则换行,同样,也能限制列数(rows),不过输入是无限循环的,示例如下:
请输入个人说明:<textarea cols="10" rows="1"></textarea></label>
0 0
原创粉丝点击