-
<script language= "JavaScript" type= "text/javascript">
-
<!--
-
// 说明:有初始值的 form 表单元素重置(reset)解决方案
-
// 整理:http://www.CodeBit.cn
-
function clearForm (formName ) {
-
var formObj = document. forms [formName ];
-
var formEl = formObj. elements;
-
for ( var i= 0; i<formEl. length; i++ )
-
{
-
var element = formEl [i ];
-
if (element. type == 'submit' ) { continue; }
-
if (element. type == 'reset' ) { continue; }
-
if (element. type == 'button' ) { continue; }
-
if (element. type == 'hidden' ) { continue; }
-
if (element. type == 'text' ) { element. value = ''; }
-
if (element. type == 'textarea' ) { element. value = ''; }
-
if (element. type == 'checkbox' ) { element. checked = false; }
-
if (element. type == 'radio' ) { element. checked = false; }
-
if (element. type == 'select-multiple' ) { element. selectedIndex = -1; }
-
if (element. type == 'select-one' ) { element. selectedIndex = -1; }
-
}
-
}
-
//-->
-
</script>
有初始值的 form 表单元素重置(reset)解决方案
最新推荐文章于 2021-10-12 17:58:58 发布