且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在所生成的网址中将%+替换为%20

更新时间: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 );
    });
});

相关阅读

技术问答最新文章