본문 바로가기
개발/javascript

javascript form reset 초기화

by 향유 2021. 1. 19.

form reset 초기화

 

1.폼에 id 값을 지

<form name="form_apply" id="form_apply" method="post" action="?tpf=sub/process" enctype="multipart/form-data">

 

2. 스크립트 선언

function form_reset() {

    document.getElementById("form_apply").reset();

}

 

3. 실행 버튼

      <img class="closebt" onclick="form_apply_reset();form_reset()" src="/html/images/closebt.svg">

 

 

출처:http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_reset

 

Tryit Editor v3.6

Enter some text in the fields below, then press the "Reset form" button to reset the form. First name: Last name: function myFunction() { document.getElementById("myForm").reset(); }

www.w3schools.com

댓글