Form acceptCharset Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form


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

Set the acceptCharset property with the following Values

Value Description
character-set A space- or comma-separated list of one or more character encodings that are to be used for the form submission.

Common values:

  • UTF-8 - Character encoding for Unicode
  • ISO-8859-1 - Character encoding for the Latin alphabet.

Return Value

A String, representing the character set(s) that the server should use for form submission

The following code shows how to return the character-set the server should use for form submission:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form id="myForm" accept-charset="ISO-8859-1">
  First name: <input type="text" name="fname" value="Donald"><br>
  Last name: <input type="text" name="lname" value="Duck"><br>
</form>/* w w w .j  av  a 2s  . c  o  m*/

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

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

function myFunction() {
    var v = document.getElementById("myForm").acceptCharset;
    document.getElementById("demo").innerHTML = v;


Related Tutorials