Disallow Characters in Username Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    Disallow Characters in Username

    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Disallow Characters in Username

    Post by nextlevelgaming October 20th 2012, 7:12 pm

    Hey Rideem, LG, Sanket, or anyone else. I'm looking through the ACP and trying to find if there is a section where we can disallow a certain character.
    Reason I ask Rideem is this is for your code, and my click function code, you say no spaces allowed in the username correct? How would I make it so no users can create a space in their username.
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Disallow Characters in Username

    Post by LGforum October 20th 2012, 7:35 pm

    ACP - General - Username Censoring.

    Just put '* *' without the speech marks as a censor. That should prevent spaces in usernames.
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 20th 2012, 10:13 pm

    No I know about the %20, but I don't believe users will remember so, instead I will disallow the space altogether. they can use other things to give it a space lol. And thanks LG let ya know if it worked

    Did not work

    I added it like so * *
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Disallow Characters in Username

    Post by LGforum October 22nd 2012, 1:08 am

    Could try *%20*
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 22nd 2012, 1:12 am

    with the asteriks? Cuz I tried %20 and ' ' "That is three spaces without the speech marks.
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Disallow Characters in Username

    Post by LGforum October 22nd 2012, 1:18 am

    Yes the asterisks are wildcards. Meaning that they can mean any amount of any thing.
    So *%20* means, a space with any amount of anything before it, and any amount of anything after it. Essentially censoring any usage of a space in a username.
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 22nd 2012, 1:20 am

    okie dokie ill try er out LG

    Ok so did not work as well. This is frustrating me quite a bit actually. Something sooo simple ya know... What about this code

    Code:
    <script type="text/javascript">

    function nospaces(t){

    if(t.value.match(/\s/g)){

    alert('Sorry, you are not allowed to enter any spaces');

    t.value=t.value.replace(/\s/g,'');

    }

    }

    </script>

    And add this to username field
    Code:
    onkeyup="nospaces(this)"

    Though I don't know where the registration username field so located in templates...
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Disallow Characters in Username

    Post by LGforum October 22nd 2012, 3:50 am

    Yes you could do that. Though I don't know why the censor won't allow a space...

    You could add an event listener (may as well jQuery it):
    Code:
    $('#username_reg').keyup(function(e) {
        if(e.keyCode === 32) alert('No space are allowed in usernames');
    });
    But people can get passed it if they disable Javascript ... however chances of them doing that are very small, unless they are just trying to be annoying Razz
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 22nd 2012, 5:00 am

    cheers I hope this works, and I know I was hoping it would censor it! Be alot easier then having to do another code. What would happen if they had it disabled? No alert?
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 23rd 2012, 12:31 am

    No, neither codes worked, nor did the alert show. So I am still focusing on figuring this out. I want to keep this open incase someone needs this, and I find the answer
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 23rd 2012, 1:29 am

    Code:
    $(window).ready(function(){
    ?
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 23rd 2012, 1:31 am

    Ill try it again. Sorry man, didn't know what ya meant lol

    worked like a charm Smile

    Now how come

    Code:
    $(function() {
    $('#username_reg').keyup(function(e) {
        if(e.keyCode === 32) alert('No space are allowed in usernames');
    });
    });
    that worked

    and this does not?

    Code:
    $(window).ready(function() {
    $('#username_reg').keyup(function(e) {
        if(e.keyCode === 32) alert('No space are allowed in usernames');
    });
    });

    I get the above u gave is DOM. but can you explain the differences please?
    LGforum
    LGforum
    Hyperactive


    Male Posts : 2265
    Reputation : 264
    Language : English
    Location : UK

    Solved Re: Disallow Characters in Username

    Post by LGforum October 23rd 2012, 1:36 am

    Window, doesn't have a ready listener. It has a 'onload' event.

    So you could do $(window).load(function(){ , or window.onload = function() {
    However, DOM Readiness comes before the window is loaded.
    nextlevelgaming
    nextlevelgaming
    Forumember


    Male Posts : 989
    Reputation : 38
    Language : English|CSS|HTML5|javascript|
    Location : New York

    Solved Re: Disallow Characters in Username

    Post by nextlevelgaming October 23rd 2012, 1:44 am

    Yes sir, thank you very much for the explanation. And now, your tagging system, and my click func. Is going to be perfect on my site Smile