java怎么实现随机4个带有数字和字母的验证码?
参考代码:
private String generateWord() {
String[] beforeShuffle = new String[] { "2", "3", "4", "5", "6", "7",
"8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z" };
List list = Arrays.asList(beforeShuffle);
Collections.shuffle(list);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
}
String afterShuffle = sb.toString();
String result = afterShuffle.substring(5, 9);
return result;
}
求java表单验证制作注册页面的代码?
简单举例:
function checkForm(){
var username =document.getElementById('username').value;
var pwd=document.getElementById('pwd').value;
var rePwd=document.getElementById('rePwd').value;
var email=document.getElementById('email').value;
var checkAgree=document.getElementById('checkAgree');
var form=document.getElementById('form');
var emailReg=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ ;
if(username==''){
alert('用户名不能为空');
document.getElementById('username').focus();
return false;
}
if(pwd==""){
//不能为空
}
if(pwd.lentht
//长度不能小于6位
}
if(pwd!=rePwd){
//密码确认密码不一致
}
//日期的话建议用日历控件 可以参考网上自己弄一弄
if(!emailReg.test(email)){
//邮箱格式不对
}
if(!checkAgree.checked){
//尚未统一协议
}
//所有验证通过之后提交表单
();
}
写了基本的东西出来 还是希望你能自己研究研究 自己动手搞定