Javascript DOM HTML Form acceptCharset Property get

Introduction

Return the character-set the server should use for form submission:

var x = document.getElementById("myForm").acceptCharset;

Click button to return the value of the accept-charset attribute in the form element.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm" accept-charset="ISO-8859-1">
  First name: <input type="text" name="fname" value="CSS"><br>
  Last name: <input type="text" name="lname" value="HTML"><br>
</form>//from   w  w  w .j a  va2s. c  om
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  var x = document.getElementById("myForm").acceptCharset;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The acceptCharset property sets or gets the value of the accept-charset attribute in a form element.

The accept-charset attribute sets the character-sets that are to be used for the form submission.

The default value is the reserved string "UNKNOWN".

It indicates that the encoding equals the encoding of the document containing the <form> element.

Property Values

Value
character-set



Description
A space- or comma-separated list of one or more character encodings
Common values:
UTF-8 - Character encoding for Unicode
ISO-8859-1 - Character encoding for the Latin alphabet

The acceptCharset property returns a String representing the character set(s).




PreviousNext

Related