/    Sign up×
Community /Pin to ProfileBookmark

join() Function Question

Hi,

I am most definitely a nOObie with javascript…here is my issue.

I have a form which has 3 fields:

[list]

  • [*]

    login


  • [*]

    firstname


  • [*]

    lastname


  • [/list]

    Login is a hidden field, firstname and lastname are both text fields

    When a user joins I need to join the firstname and lastname together AND replace any spaces with an underscore. So if someone with the firstname of JOHN and lastname of DOE registers I need the value of login to be set to john_doe

    No that part is somewhat easy for me to understand how to do, but what if someone has the name of firstname Mary Jane and lastname De Martin how can I replace all of the spaces with underscores AND change the case to all lower? I know there has to be a way to do this with Javascript, but I just don’t know how. Yes I realize not everyone has javascript, but this form is a registration for a PRIVATE site and I am willing to deal with that if it happens.

    So to recap I need to join firstname and lastname values, remove all spaces and replace them with underscores, and change the case to all lowercase, and assign the value to login

    Thanks in advance,

    Chad

    to post a comment
    JavaScript

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @Arty_EffemOct 09.2006 — 
    Thanks in advance,

    [/QUOTE]


    [CODE]
    <input type=button value='OK' onclick="this.form.login.value=(this.form.firstName.value+'_'+this.form.lastName.value).replace(/s+/g,'_').toLowerCase()">
    [/CODE]
    Gratitude accepted in advance.
    ×

    Success!

    Help @logdir spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...