Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6024969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:14:02+00:00 2026-05-23T04:14:02+00:00

Here’s what I’m looking for. In my form I have three fields, all CharFields.

  • 0

Here’s what I’m looking for. In my form I have three fields, all CharFields. Those are Name, Surname and Username. Username should be set as a sum of Name and Surname, so for Name = Joe, Surname = Black, Username = Joe Black.

As the form is displayed, all fields all empty. I’d like it to auto-populate the Username while i’m writing data to a Name or a Surname. The reason of this is that I don’t have to fill the Username field, but when I’d like to, I will be able to set it different than Name + Surname.

Is it possible without using jQuery? If so, is there any good tutorial on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:14:03+00:00Added an answer on May 23, 2026 at 4:14 am

    javascript

    <script type="text/javascript" charset="utf-8">
    
        function updateUsername(){
            first = document.getElementById("first").value;
            last = document.getElementById("last").value;
            document.getElementById("username").value = first+" "+last;
        }
    
    </script>
    

    then you need to give your 3 input fields IDs.

    Here’s a example

    <input type="text" name="some_name" value="" id="first" onkeyup="updateUsername();">
    <input type="text" name="some_name" value="" id="last" onkeyup="updateUsername();">
    <input type="text" name="some_name" value="" id="username">
    

    Basically when the #first and #last field are typed into it runs the updateUsername() function which gets their values and changes the value of #username to them.

    EDIT

    If you want to do this with django, edit your model and overwrite the save method.

    def save(self):
        if not self.id:
            self.username = self.first + self.last
        super(MODLE_NAME, self).save()
    

    What that’ll do is when you use the save() method, it’ll take it’s first and last properties and update the username value and save it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here we go again, the old argument still arises... Would we better have a
I have a jquery bug and I've been looking for hours now, I can't
Here is a snippet of my form <form action= method=post onsubmit=return verify()> <input type=submit
Here, i have coded to get data from DB. I want to store the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.