<script type="text/javascript" src="system/common/Util.js"></script>
<script language="JavaScript">
function _check(){
var valid = true;
var username = document.getElementById("username");
var password = document.getElementById("password");
var email = document.getElementById("email");
if(username.value.Trim() == ""){
window.alert("用户名不能为空!");
username.value="";
username.focus();
valid = false;
return valid;
}
if(CheckIllegalCharacter(username.value.Trim())){
alert("用户名含有非法字符");
valid = false;
return valid;
}
if(password.value.Trim().length<4){
window.alert("密码不能为空且长度不能小于4个字符!");
password.value="";
password.focus();
valid = false;
return valid;
}else{
var idx = email.value.Trim().indexOf('@');
if(idx<=0 || idx==email.value.Trim().length-1){
alert("Email地址格式不合法!");
email.focus();
valid = false;
return valid;
}
} //window.alert(username.value.Trim().TagTrim().length);
//window.alert(password.value.Trim().length);
//window.alert(email.value.Trim().length);
if(valid){
document.myform1.submit();
}
}
</script>
-------------------------------------------------------------------
<form action="http://www.baidu.com" name="myform1" οnsubmit="return _check()">
username:<input type="text" id="username" name="username"><br>
password:<input type="password" id="password" name="password"><br>
email:<input type="text" id="email" name="email"><br>
<input type="submit" name="tijiao"><br>
</form>
<!--EndFragment-->