📜  javascript sanitize input slug - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:32.106000             🧑  作者: Mango

代码示例1
// https://stackoverflow.com/a/1054862/485063
    jq('.input.slug, .slug, input .slug').unbind().bind('keyup paste', function(){
        var low=    jq(this).val().toLowerCase()
            .replace(/ /g,'-')
            .replace(/\_/g,'-')
            .replace(/[^\w-]+/g,'')
            .replace(/\-\-+/g,'-');
        
        jq(this).val(low);
    });