html表单单个reset功能实现

lovehuayud 2012-04-27

表单的reset,无非是吧表单域的值还原成了defaultValue的值。

如果想实现全部表单的reset,则可以遍历所有的表单,然后将value值设置为defaultValue即可。

this.value = this.defaultValue;

为form表单添加reset功能:

   function _3080(_3090){

$("input,select,textarea",_3090).each(function(){

if($(this).hasClass("combo-text")||$(this).hasClass("combo-value")){

return;

}

if($.fn.combobox&&$(this).hasClass("combobox-f")){$(this).combobox("reset");return;}

if($.fn.combotree&&$(this).hasClass("combotree-f")){$(this).combotree("reset");return;}

if($.fn.combogrid&&$(this).hasClass("combogrid-f")){$(this).combogrid("reset");return;}

if($.fn.datebox&&$(this).hasClass("datebox-f")){$(this).datebox("reset");return;}

if($.fn.datetimebox&&$(this).hasClass("datetimebox-f")){$(this).datetimebox("reset");return;}

if($.fn.combo&&$(this).hasClass("combo-f")){$(this).combo("reset");return;}

vart=this.type,tag=this.tagName.toLowerCase();

if(t=="text"||t=="hidden"||t=="password"||tag=="textarea"){

this.value=this.defaultValue;

}else{

if(t=="checkbox"||t=="radio"){

this.checked=this.defaultValue;

}else{

if(tag=="select"){

this.selectedIndex=this.defaultValue;

}

}

}

});

    };

相关推荐

谢文浩 / 0评论 2017-02-08
阿祖哥 / 0评论 2015-05-28
whyherry / 0评论 2017-02-08

webhwg / 0评论 2015-10-13