JavaScript에서 폼 버튼

폼은 버튼을 눌러서 제출된다는 것을 이미 알고 계실 것입니다. 그러나 여기에는 세부 사항이 있습니다. 버튼은 반드시 type 속성을 submit 값으로 가져야 합니다:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <input type="submit">
</form>

type 속성이 submit 값으로 설정된 button 태그도 폼을 제출합니다:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <button type="submit">btn</button>
</form>

또한 입력 필드 중 하나에 포커스를 두고 Enter 키를 누르면 폼이 제출됩니다.

type 속성이 button 값으로 설정된 버튼은 페이지 요소로 사용되며 폼을 제출하지 않습니다:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <input type="button">
</form>

button 태그도 동일하게 작동합니다:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <button>btn</button>
</form>

type 속성이 reset 값으로 설정된 버튼은 작성된 폼을 지웁니다:

public/form.html<form>
  <input name="test1">
  <input name="test2">
  <input type="reset">
  <input type="submit">
</form>
Задание 1

다음 코드를 수정하여 버튼이 서버로 폼을 제출하도록 만드세요:

html<form>
  <input name="name">
  <input name="surn">
  <button>send</button>
</form>