表单

提示:运行没有出错,但功能不显示的话建议去看看函数命名是不是取对了
1.maxlength:控制字符个数
2.textarea没有maxlength属性 需要自定义来控制输入字符的个数 输入字符个数与自定义个数相比较 返回true/false 每输入一次(onkeypress)就比较一次
3.鼠标经过时自动选择文本 “this.focus()”
“this.select()”
4.多选:< select name=“country1” id=“country11” multiple=“multiple”>

< html lang=“en”>
< head>
< meta charset=“UTF-8”>
< title>formm< /title>
< /head>
< script type=“text/javascript”>
//全选
function alls(){
var a=document.form11.styple;
for(var i=0;i<a.length;i++){
a[i].checked=true;
}
}
//全不选
function nulls(){
var a=document.form11.styple;
for(var i=0;i<a.length;i++){
a[i].checked=false;
}
}
//反选
function reverse(){
var a=document.form11.styple;
for(var i=0;i<a.length;i++){
a[i].checked=!a[i].checked;
}
}

//控制输入字符个数
function count(b){
return b.value.length<b.getAttribute(“maxlength”);

}
< /script>
< body>
< form name=“form11” method=“post”>
< lable>姓名:< /lable>
< br>
< input type=“text” placeholder=“字符数不超过5” maxlength=“5” “this.focus()” “this.select()”>
< br>
< label>密码< /label>
< br>
< input type=“password” placeholder=“请输入不超过6位数的密码” maxlength=“6”>
< br>
< div id=“country”>
< label >最喜欢哪国食物< /label>
< br>
< select name=“country1” id=“country11” >
< option >中国< /option>
< option selected=“selected”>韩国< /option>
< option>美国< /option>
< option>法国< /option>
< /select>
< /div>
< br>
< div id=“sex”>
< label>性别< /label>
< br>
< input type=“radio” name=“sex” id=“male” value=“male”>< labe for=“male”>男< /labe>
< input type=“radio” name=“sex” id=“female” value=“female”>< label for=“female”>女< /label>
< /div>
< br>
< div id=“food”>
< label>口味< /label>
< br>
< input type=“checkbox” name=“styple” id=“sour” value=“sour”>< label for=“sour”>酸< /label>
< input type=“checkbox” name=“styple” id=“sweet” value=“sweet”>< label for=“sweet”>甜< /label>
< input type=“checkbox” name=“styple” id=“spicy” value=“spicy”> < label for=“spicy”>辣< /label>
< br>
< input type=“button” value=“全选” “alls()”>
< input type=“button” value=“全不选” “nulls()”>
< input type=“button” value=“反选” “reverse()”>
< /div>
< br>
< div id=“content”>
< label>留言< /label>
< br>
< textarea id=“message” rows=“4” cols=“20” maxlength=“40” “return count(this)”>< /textarea>
< /div>
< br>
< div id=“important”>
< input type=“submit” value=“提交”>
< input type=“reset” value=“重置”>
< /div>
< /form>
< /body>
< /html>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值