如果 reg id 为空或为空,我需要以<Reg id:>
红色显示文本。这是我当前的实现,但警告,颜色没有改变。
<html>
<head>
<script type="text/javascript">
function ValidateForm() {
var stu_regid = document.forms["detail"]["regid"].value;
if ((null == stu_regid) || (stu_regid == "")) {
alert("Reg is should not be left blank");
// here change the color to red
document.getElementsByName("font_regid").innerHTML = "red";
return false;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%!String font_regid = new String();%>
<form name="detail" action="ReportGenerator" method="get"
onsubmit="return ValidateForm()">
<font color=<%=font_regid%>>Reg id:</font>
<input type="text" name="regid"><br>
// some code here also
<input type="submit" value="submit">
</form>
</body>
</html>