I have a textbox where the user is supposed to type in a subdomain but the root domain is always going to be the same. So I want to append the root domain like ".example.com" so if the user wants to make it "test.example.com" they only have to type "test". Following Append text to input field I can get this to work if I wait to append the text until the user is done with the field, but to clearly show the user the main domain is appended for them I want the append to happen as they type, not knowing Javascript I did this:
<input class="form-control" type="text" name="subdomain" id="subdomain" placeholder=".example.com" oninput="$('#subdomain').val($('#subdomain').val() + '.example.com');">
I am sure you can see what is going wrong, ".example.com" keeps getting appended with every key press so I end up with something like "te.example.com.example.com" as I type. Is there an easy way to make it to where it is just appended only once?