日期:2014-05-16  浏览次数:20365 次

submit
onsubmit时的一个检测函数,可是返回的结果都是true  

var   check_object1   =   new   check_Object( " ", " ", " ");
只要上面的参数不为空,就提交了,不知道为什么


////////////////////////////////////////////////////////////

onsubmit= "javascript:return   check_addlisting(this.form); "

//check   object  
function   check_Object(typeid,nametext,nameform){
this.typeid   =   typeid   ;  
this.nametext   =   nametext   ;  
this.nameform   =   nameform   ;  

this.get_nameform   =   function(){
return   this.nameform   ;   //问题可能在这里?

}
this.get_typeid   =   function(){
return   this.typeid   ;  
}
this.get_nametext   =   function(){
return   this.nametext   ;  
}

}


//check   type  
function   check_type(check_object_instance){
this.typeid   =   check_object_instance.get_typeid()   ;  
this.nameform   =   check_object_instance.get_nameform()   ;  
this.nametext   =   check_object_instance.get_nametext()   ;  

this.check   =   function(){
switch(this.typeid){
case   "1 ":   {//check   null  
  return   this.check_null()   ;  
}
case   "2 ":{//check   "-1 "
  return   this.check_any()   ;  
}
default:{
return   false   ;  
}

}

}

this.check_null   =   function(){
if(this.nametext.value   ==   " "){
return   false   ;  
}
}
this.check_any   =   function(){
if(this.nametext.value   ==   "-1 "){
return   false   ;  
}
}
}


//---------------------------------------check  
//check   addlisting 's   form  
function   check_addlisting(nameform){

var   check_object1   =   new   check_Object( "2 ",nameform.type2,nameform)   ;  

var   check_type1   =   new   check_type(check_object1)   ;  

return   check_type1.check()   ;  


return   false   ;  
}

------解决方案--------------------
/**
this.get_nameform = function(){
return this.nameform ; //问题可能在这里?

}
this.get_typeid = function(){
return this.typeid ;
}
this.get_nametext = function(){
return this.nametext ;
}
**/
把上面三句合成一句:return this;//其它属性直接引用,后续处理就是检测数据;
------解决方案--------------------
看不出來.