日期:2014-05-16 浏览次数:20384 次
var usernamePatrn = /^([a-zA-Z0-9]|[_]){6,20}$/; if(!usernamePatrn.test(form.username.value)){ alert("用户名输入按照规则"); return false; }
//去掉空格 function ltrim(s){ for(var i=0;i<s.length;i++) if(s.charAt(i)!=' ') return s.substring(i,s.length); return ""; }
<input type=button name="checkall" value="全选" onClick="this.value=check(this.form.checkbox)"> var checkflag = "false"; function check(field) { if (checkflag == "false") { for (i = 0; i < field.length; i++) { field[i].checked = true; } checkflag = "true"; return "取消"; }else { for (i = 0; i < field.length; i++) { field[i].checked = false; } checkflag = "false"; return "全选"; } }
<input type=submit name="del" value="删除" onClick="return checkDel();"> //选择删除 function checkDel(){ var check_id=document.getElementsByName("checkbox"); var id=""; for(i=0;i<check_id.length;i++){ if(check_id[i].checked){ id+=check_id[i].value+"##"; } } if (id=="") { alert ("请至少选择1个"); return false; } document.getElementById("userid").value=id; }[