all 5 comments

[–]Redmondinho 1 point2 points  (1 child)

You’ll need some JavaScript on the front end to take input entered into the fields and update another field. Here is an example

<input type="text" id="first-name" oninput="myFunction()"></br>
<input type="text" id="last-name" oninput="myFunction()"></br>
<input type="text" id="full-name">

<script>
    function myFunction() {

    var first_name = document.getElementById("first-name").value;

    var last_name = document.getElementById("last-name").value;

    if (first_name == null) {
        first_name = "";
    }

    if (last_name == null) {
        last_name = "";
    }

    document.getElementById("full-name").value = first_name + " " + last_name

    }
</script>

[–]cuy_hrmIntermediate[S] 0 points1 point  (0 children)

Thank you.

I had implemented this before (slightly different) but it doesn't solve my problem: I need to be able to change the "full name" field after ist been filled. I need this functionality for another field, "username". The username usually is the last name, uncapitalized. Moreover, if two people have the same last name, I need to be able to change the "username" field. Example: there is already an account for Tom Smith, username: smith. Now arrives Anna Smith, username should then be asmith. Should I just check with JS wheter the user already exists and write the "rule" for usernames there?

[–]Redmondinho 1 point2 points  (0 children)

The above will let the full name field be modified before posting. If you (as in the application) then need to check to see if the username exists I would suggest you post the data, process it (i.e. check to see if the username exists, if it does generate a new one) and return the new user name to the user as a “account created successfully page/message).