<commit_before>$(document).ready( function(){

strip = function(s) { return s.replace(/^\s+/, '').replace(/\s+$/, ''); }
remove_punctuation = function(s) { return s.replace(/[,.;]/g,''); }

$('#ptitle').change(function fillURL(){
    if(! $('#pid').attr('readonly')){
        url = strip(this.value).toLowerCase().replace(/\s+/g, '-');
        url = remove_punctuation(url);
        $('#pid').val(url);
        $('#pid').change(); //is this required?
    }    
    return;
});

$('#pid').change( function checkID(){
    $.post('/c/checkID', {pid: strip(this.value)},
         function(available){
            if (available == 'False'){
                msg = 'ID already exists, Choose a different one';
                $('#note_pid').html('<strong style="color:red">' + msg + '</strong>');
                $('#pid').focus();
                return false;
            }
            else { 
                $('#note_pid').html('');
                return true;
            }
        });
    });
});
<commit_msg>Remove all non-alphanumeric characters when copying title to url. Also copy title on blur event<commit_after>$(document).ready( function(){

strip = function(s) { return s.replace(/^\s+/, '').replace(/\s+$/, ''); }
remove_punctuation = function(s) { return s.replace(/[^a-z0-9-]/g,''); }

var ptitle_event = function fillURL(){
    if(! $('#pid').attr('readonly')){
        url = strip(this.value).toLowerCase().replace(/\s+/g, '-');
        url = remove_punctuation(url);
        $('#pid').val(url);
        $('#pid').change(); //is this required?
    }    
    return;
}

$('#ptitle').change(ptitle_event);
$('#ptitle').blur(ptitle_event);

$('#pid').change( function checkID(){
    $.post('/c/checkID', {pid: strip(this.value)},
         function(available){
            if (available == 'False'){
                msg = 'ID already exists, Choose a different one';
                $('#note_pid').html('<strong style="color:red">' + msg + '</strong>');
                $('#pid').focus();
                return false;
            }
            else { 
                $('#note_pid').html('');
                return true;
            }
        });
    });
});

{'fraction_non_alphanumeric': 0.22478120681713495, 'fraction_numerical': 0.0009212344541685859, 'mean_word_length': 2.1478260869565218, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1641516', 'n_tokens_mistral': 647, 'n_tokens_neox': 642, 'n_words': 126}