<script>
function check() {
var obj = document.getElementById;
var username = obj("txt_username");
var password = obj("txt_pwd");
var checkcode = obj("txt_code");
if(_do(username, "请填写用户名")&&
_do(password, "请填写密码")&&
_do(checkcode, "请填写验证码"))
document.forms[0].submit();
}
function _do(obj,msg) {
if (obj.value == "") {
alert(msg);
obj.focus();
return false;
}
else
return true;
}
</script>
转载于:https://www.cnblogs.com/QiuJL/archive/2011/08/08/4524304.html