Search code examples
javascriptjqueryhtmltwitter-bootstrapjavascript-objects

Lowercase and merge words together in JavaScript value


I can't seem to figure out what's going on on a form field input that gets stored inside a SharePoint column data collection.

I have a form field set when someone inputs a name that it automatically gets populated in a SharePoint list:

enter image description here

Here is what I currently have:

Output:
Profile Username: fhWestern Union

This is what I want to be able to achieve on all the inputs:

Output:
Profile Username: fhwesternunion

Here is the currently JavaScript code bit that I have grabbing the data:

ACI_Username: "fh" + $("#ACI_client-name-input").val(), // Username

I have tried adding this below and it did not work with my code.

.toLowerCase().val()


Solution

  • Replace

    $("#ACI_client-name-input").val()
    

    With

    $("#ACI_client-name-input").val().replace(/\s+/g,'').toLowerCase()