form1.class.value
不要用class做名字
不要用class做名字
解决方案 »
- 两个js文件之间如何传参
- javascript问题:一个2行2列的表格,怎么按顺序改变表格的颜色?望高手不吝赐教。
- 在ie的地址栏里输入网址后,当页面打开的时候,如何自动隐藏ie地址址,状态栏,全屏等...
- document.execCommand("CreateLink", false, "不能指定缺省值?")
- javascript向事件傳遞函數時的問題,高分哦:)
- 后台取值中包含 ' " 转换js的字符串问题
- 打印IE网页的时候,只能纵向分页,不能横向分页是吗?
- 有没有参数可以把IE浏览器的最上端的关闭按钮的那个条可以隐藏
- textbox里面取值问题
- 如何在自定义类中声明私有数据和私有方法
- 这样写有什么错误,帮忙改一下.
- 高分聘请高手解答 我已经困惑快2周了 在线等送分!
它提示是在year,month,day那一块,我也搞不懂了??
<head>
<title>
添加新记录
</title>
<LINK href="comDB/article.css" rel=stylesheet type=text/css><script language="JavaScript">
<!--
var bCheck=false;//当前是否处于验证状态
var bChecked=false;//输入框是否处于焦点状态
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}String.prototype.Trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}String.prototype.getLength = function(){
var l=this.length;
var n=l
for (var i=0;i<l;i++){
if (this.charCodeAt(i)<0||this.charCodeAt(i)>255) n++
}
return n
}function check(){
if(bChecked==true) return false;
bCheck=true;
var inputs=document.frmAdd.all.tags("INPUT"); for(var i=0;i<inputs.length;i++){
//去掉所填项目左右空格
var tmp=inputs[i].value;
inputs[i].value=tmp.Trim(); //如果必填项未填,要求填写
if(inputs[i].value.length<=0 && inputs[i].style.isnullable==0){
alert("请填写 ["+ inputs[i].style.name + "] 的相关信息。\n注:带有'*'号的项目为必填项目,请全部填写。");
inputs[i].focus();
bCheck=false;
return false;
} //如果超过允许的最大长度,要求重新填写
/*
if(inputs[i].value.getLength()>inputs[i].style.maxlength && inputs[i].style.maxlength>0){
alert("'" + inputs[i].style.name + "' 允许输入的最大字符数是:" + inputs[i].style.maxlength +"\n 请您重新输入。");
inputs[i].focus();
return false;
}
*/
}//end for(var i=0;i<inputs.length;i++) bCheck=false;
return true;
}function testCheck(obj){
if(bCheck==true) obj.select();
bCheck=false;
bChecked=true;
}
//-->
</script></head>
<body>
<form name=frmAdd method="POST" onsubmit="return check()" action="UploadAdd.jsp" >
<div align="center">
<table border="1" cellspacing="0" width="60%"
bgcolor="#F0F8FF" bordercolorlight="#11B1FF" bordercolordark="#F0F8FF">
<tr>
<td width="100%" bgcolor="#0080C0" height="20">
<div align="center">
<p><b><font
color="#FFFFFF">添加新记录</font></b>
</div>
</td>
</tr>
<tr align="center">
<td width="100%">
<table bgColor=#f0f8ff border=1 borderColorDark=#ecf5ff borderColorLight=#4da6ff cellSpacing=0 width="100%"> <tr>
<td width="38%" align="left" height="30" nowrap> <b><font color="#0080C0">
权限编码<font color=#FF0000 > *</font></font></b></td>
<td width="62%" height="30"><!-- 在此添加其他输入框的代码 !--> <input type="Text" value=
"" name="Code" size="70" class="smallinput" style="width:100%;isnullable:0;name:权限编码;maxlength:2"
onblur='bChecked=false;if(this.value.getLength()>2) {alert("[权限编码] 的最大长度是2,请重新填写。");bCheck=true;this.focus();return false;}' onfocus=testCheck(this)>
<tr>
<td width="38%" align="left" height="30" nowrap> <b><font color="#0080C0">
权限级别<font color=#FF0000 > *</font></font></b></td>
<td width="62%" height="30"><!-- 在此添加其他输入框的代码 !--> <input type="Text" value=
"" name="Class" size="70" class="smallinput" style="width:100%;isnullable:0;name:权限级别;maxlength:1"
onblur='bChecked=false;if(this.value.getLength()>1) {alert("[权限级别] 的最大长度是1,请重新填写。");bCheck=true;this.focus();return false;}' onfocus=testCheck(this)>
<tr>
<td width="38%" align="left" height="30" nowrap> <b><font color="#0080C0">
说明<font color=#FF0000 > *</font></font></b></td>
<td width="62%" height="30"><!-- 在此添加其他输入框的代码 !--> <input type="Text" value=
"" name="Re" size="70" class="smallinput" style="width:100%;isnullable:0;name:说明;maxlength:50"
onblur='bChecked=false;if(this.value.getLength()>50) {alert("[说明] 的最大长度是50,请重新填写。");bCheck=true;this.focus();return false;}' onfocus=testCheck(this)>
<input name="paramTableName" type =hidden value="popedom">
<input name="paramSubmitAdd" type=hidden value="True">
<input name="paramAfterAdd" type=hidden value="http://localhost:8080/PDMShow.jsp">
<input name="paramSQLWhere" type =hidden value=""> </table>
</td>
</tr>
</table>
</div>
<div align="center">
<p>
<input type="submit" value=" 确 定 " name="cmdok" class="buttonface" >
<input type="reset" value=" 复 原 " name="cmdcancel" class="buttonface">
<input type="button" value=" 返 回 " name="cmdreturn" class="buttonface" onclick="MM_goToURL('self','http://localhost:8080/PDMShow.jsp');return document.MM_returnValue">
</p>
</div>
</form>
</body>
</html>
form1.newstext.select();
是newstext还是newtext?
head,year,month,day是下拉列表框
对于这段代码,你可以来个查找替换,如将class、title都换成myclass、mytitle等等
function checkform(form1)
{
if(form1.mytitle.value.length==0)
{
form1.mytitle.focus();
form1.mytitle.select();
alert("您的新闻没有标题吗?");
return false;
}
if(form1.myhead.value=="")
{
form1.myhead.focus();
form1.myhead.select();
alert("请选择新闻类型!");
return false;
} if((form1.myyear.value==""))
{
form1.myyear.focus();
form1.myyear.select();
alert("请填写新闻发布日期!");
return false;
}
if(form1.mymonth.value=="")
{
form1.mymonth.focus();
form1.mymonth.select();
alert("请填写新闻发布日期!");
return false;
}
if(form1.myday.value=="")
{
form1.myday.focus();
form1.myday.select();
alert("请填写新闻发布日期!");
return false;
}
if((form1.myclass.value=="3") && (form1.mypic.value.length==0))
{
form1.mypic.focus();
form1.mypic.select();
alert("您输入的是图片新闻,请选择合适的图片!");
return false;
}
if(form1.mytext.value.length==0)
{
form1.mytext.focus();
form1.mytext.select();
alert("新闻内容必须填写!");
return false;
}
}</script>
<script>
function mycheck()
{
alert("text="+form1.myyear.options[form1.myyear.selectedIndex].text);
alert("value="+form1.myyear.options[form1.myyear.selectedIndex].value);
if(form1.myyear.selectedIndex==0)
{
form1.myyear.focus();
//form1.myyear.select();//对于select元素,不可以用select方法(也没必要啊,不是text嘛),清楚了吗
alert("请选择新闻发布年!");
return false;
}
}
</script>
<form name=form1>
<select name=myyear>
<option value=year>年</option>
<option value=2000>2000</option>
<option value=2001>2001</option>
<option value=2002>2002</option>
<option value=2003>2003</option>
</select>
<input type=button value=check onclick=mycheck()>
</form>