Input Submit formEnctype Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Submit

Description

The formEnctype property sets or gets the formenctype attribute of a submit button, which identifies how form-data should be encoded when submitting it to the server (only for forms with method="post").

The formenctype attribute overrides the enctype attribute of the <form> element.

Set the formEnctype property with the following Values

Value Description
application/x-www-form-urlencoded Default. All characters are encoded before sending
multipart/form-data No characters are encoded. This value is required for a file upload control
text/plainSpaces are converted to "+" symbols, but no special characters are encoded

Return Value

A String, representing the type of content that is used to submit the form to the server

The following code shows how to check how form-data should be encoded before submitting it to a server:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page_binary.asp" method="post">
  Name: <input type="text" name="fname" value="your name"><br>
  <input type="submit" id="mySubmit" formenctype="text/plain" value="Submit">
</form>/*ww w .ja  va2 s .c  o m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var v = document.getElementById("mySubmit").formEnctype;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials