I have a form containing username and password inputfields. Before submitting I would like to append the username with a string: "_test". I would like to do this, but without the user knowing/seeing this change.
function func(form){
var userName = $("#username").val() + "_test";
$("#username").val(userName);
return true;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="formtest" name="formtest" action="" method="post" onsubmit="return func(this)" >
<input name="username" type="text" autofocus id="username">
</form>
If I do something like this and the user enters "Albert", the username will briefly change into "Albert_test" before the form is submitted and the user will notice that his username has changed, I don't want this to happen. I want the visible username to remain "Albert" but I want "Albert_test" to be submitted.
An example; https://codepen.io/anon/pen/MRGmyQ As you can see, if you click the button "_test" is added, but I don't want the user to see/notice this. How can I accomplish this?
Edit: People are asking why i'm not doing this server-side. If I had any control over the server-side this would indeed be a breeze, unfortunately I can only make changes to the front-end side of things.