Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should PUT and DELETE be used in forms?

Assuming my web application has full support of PUT and DELETE on the server side, should I make use of them?

Basically my question is how many browsers support this:

<form method="PUT"> 

or

<form method="DELETE"> 

Is there any benefits to using these two HTTP Methods other than being REST-compliant? (assuming the replacement for these two methods is the commonly used POST)

like image 826
Earlz Avatar asked Mar 02 '11 03:03

Earlz


People also ask

Can I use Delete method in form?

Browsers do support PUT and DELETE but it only by using request via AJAX, but not via 'HTML form' submission. In both HTML4 and HTML5 spec, it says that the only HTTP methods that HTML form element should allow are "GET" and "POST". There is no clear reason why PUT and DELETE are not supported by 'HTML form'.

Can we use Put method in form?

According to the HTML standard, you can not. The only valid values for the method attribute are get and post , corresponding to the GET and POST HTTP methods. <form method="put"> is invalid HTML and will be treated like <form> , i.e. send a GET request.

Why are there no put and delete methods in HTML forms?

DELETE only makes sense if there is no payload, so it doesn't make much sense with forms either. At this point, it seems that the main reason why there is no support for these methods is simply that nobody has taken the time to write a comprehensive specification for it.


1 Answers

Your question involves two closely related but separate standards, HTTP and HTML. The PUT and DELETE methods are part of HTTP. In HTTP they have obvious use in RESTful interfaces, and other services which build on HTTP such as Webdav.

HTML up to version 4 only defines the use of POST and GET for forms. HTML5 at this time appears as though it may support the further methods. [note, support is not included in the current w3 draft]

Any current browser support (I'm not directly aware of any) will be very limited and only really useful as an experiment at the bleeding edge.

like image 97
leebriggs Avatar answered Oct 13 '22 06:10

leebriggs