更新时间:2023-02-23 10:09:46
Try using encodeURIComponent(str)
function.
var test = "Paul John";
var result = encodeURIComponent(test );
//result: "Paul%20John"
To replace the content just before submitting the form use this jquery code:
$(document).ready(function(){
$('.form-horizontal').submit(function(){
var encoded = encodeURIComponent($('#nickname').val().trim());
$('#nickname').val(encoded );
});
});