Change the value of the formenctype attribute of a button from "text/plain" to "application/x-www-form-urlencoded":
document.getElementById("myBtn").formEnctype = "application/x-www-form-urlencoded";
This example contains a form with a submit button that submits the form without character encoding (text/plain):
Click on button to change the value of the formenctype attribute of the submit button.
<!DOCTYPE html> <html> <body> <form action="/action_page_binary.asp" method="post"> Name: <input type="text" name="fname" value="css"><br> <button id="myBtn" type="submit" formenctype="text/plain">Submit form</button> </form>/*w w w .j a va2 s. c om*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myBtn").formEnctype = "application/x-www-form-urlencoded"; document.getElementById("demo").innerHTML = "The value of the formenctype attribute was changed."; } </script> </body> </html>