<script type="text/javascript">
String.prototype.Trim=function() {
return this.replace(/(^/s*)|(/s*$)/g,"");
}
function check() {
if(document.getElementById("user.userName").value.Trim() == "") {
alert("请输入用户名");
document.getElementById("user.userName").focus();
return false;
}
if(document.getElementById("user.userTrueName").value.Trim() == "") {
alert("请输入用户真名");
document.getElementById("user.userTrueName").focus();
return false;
}
if(document.getElementById("user.userPassword").value.Trim() == "") {
alert("请输入用户密码");
document.getElementById("user.userPassword").focus();
return false;
}
return true;
}
</script>
用户名 <input type="text" id="userName" name="user.userName" value="${user.userName}" style="width:250px">用户真名<input type="text" name="user.userTrueName" value="${user.userTrueName}" style="width:250px">
密码 <input type="password" name="user.userPassword" value="${user.userPassword}" style="width:250px">
不知道什么原因,focus没有效果
document.getElementById("user.userName").focus();