Yes it is true that decodeURIComponent function doesn’t convert + to space. So you have to replace the + using replace function.
Ideally the below solution works.
var str_name="This+is+a+message+with+spaces";
decodeURIComponent((str_name + '').replace(/\+/g, '%20'));
More Related Contents:
- JavaScript code to stop form submission
- Best way to track onchange as-you-type in input type=”text”?
- Why does forms with single input field submit upon pressing enter key in input
- Disable form auto submit on button click
- How to submit a form with JavaScript by clicking a link?
- HTML input file selection event not firing upon selecting the same file
- How to convert Base64 String to javascript file object like as from file input form?
- HTML input type=file, get the image before submitting the form
- Drop-down box dependent on the option selected in another drop-down box
- How to ensure a form field is submitted when it is disabled?
- How to prevent submitting the HTML form’s input field value if it empty
- How to prevent page from reloading after form submit – JQuery
- Property ‘submit’ of object # is not a function
- Adding rows dynamically with jQuery
- Best JavaScript solution for client-side form validation and interaction? [closed]
- HTML/JavaScript: Simple form validation on submit
- Appending form input value to action url as path
- jQuery Change event on an element – any way to retain previous value?
- How to show setCustomValidity message/tooltip without submit event
- Dynamically creating a specific number of input form elements
- How can I get all a form’s values that would be submitted without submitting [duplicate]
- How to set custom validation messages for HTML forms?
- Trigger standard HTML validation (form) without using submit button? [duplicate]
- Set the default value of an input field
- Get content of span
- form with no action and where enter does not reload page
- Copy/Paste from Excel to a web page
- copying the value of a form’s file input field to another form’s input field
- Custom Checkbox
- Disable scrolling on “