Form acceptCharsetProperty

Form 对象参考手册Form Object

Definition and Usage

The acceptCharset property sets or returns a comma-separated list of character sets that the server accepts.

Syntax

formObject.acceptCharset=value

The acceptCharset property can have the following values:

Value Description
character-set One or more character sets accepted by the server. Separate multiple character sets with commas.

Common values:

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

In theory, any character encoding can be used, but not all browsers support it. So please use common character encodings.

For all character encodings, please check this site'sCharacter Set Reference Manual。



Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the acceptCharset property.


Tips and Notes

Note:The accept-charset attribute does not work properly in IE browser. If accept-charset="ISO-8859-1", data will be sent encoded as "Windows-1252".


Example

Example

Return the value of the accept-charset attribute of the form:

<html>
<body>

<form id="frm1" 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>

<script>
document.write(document.getElementById("frm1").acceptCharset)
</script>

</body>
</html>

The output of the above example:

ISO-8859-1

Try it yourself »


Form 对象参考手册Form Object Other Extensions