JavaScript gets the web page support form character set method

  • 2020-05-26 07:45:55
  • OfStack

This article illustrates an example of how JavaScript retrieves the character set of a web supported form. Share with you for your reference. The details are as follows:

JavaScript retrieves the character set for web page support forms through the form's acceptCharset method


<!DOCTYPE html>
<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>
<p>The value of the accept-charset attribute is:
<script>
document.write(document.getElementById("frm1").acceptCharset)
</script>
</p>
</body>
</html>

The above code output:


The value of the accept-charset attribute is:ISO-8859-1

I hope this article is helpful to you in javascript programming.


Related articles: