THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Form acceptCharset Property

Form Object Reference Form Object

Example

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

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

The result of x will be:

ISO-8859-1
Try it Yourself »

Definition and Usage

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

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

The default value is the reserved string "UNKNOWN" (indicates that the encoding equals the encoding of the document containing the <form> element).


Browser Support

Property
acceptCharset Yes Yes Yes Yes Yes

Syntax

Return the acceptCharset property:

formObject.acceptCharset

Set the acceptCharset property:

formObject.acceptCharset=character-set

Property 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

In theory, any character encoding can be used, but no browser understands all of them. The more widely a character encoding is used, the better the chance that a browser will understand it.

To view all available character encodings, go to our Character sets reference.

Technical Details

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

More Examples

Example

Change the value of the accept-charset attribute in a form to UTF-8:

document.getElementById("myForm").acceptCharset = "UTF-8";
Try it Yourself »

Related Pages

HTML reference: HTML <form> accept-charset attribute


Form Object Reference Form Object