Skip to content

Instantly share code, notes, and snippets.

@AlvisonHunterArnuero
Last active April 29, 2020 04:34
Show Gist options
  • Save AlvisonHunterArnuero/fca7dd6dce5722af065a8be4147a2eee to your computer and use it in GitHub Desktop.
Save AlvisonHunterArnuero/fca7dd6dce5722af065a8be4147a2eee to your computer and use it in GitHub Desktop.
Quick question in regards generating an username based on the typed name and save it in a var
<!DOCTYPE html>
<html>
<body>
<h4>Sign Up Form Marca ACME</h4>
<p>Please type your name to generate its user name:</p>
<b>Name </b><input type="text" id="name" onkeyup="handleChange()"><br/><br/>
<b> User </b><input type="text" id="username">
<p id="displaymsg"></p>
<script>
function handleChange() {
var name = document.getElementById("name").value;
document.getElementById("username").value = name.replace(/ +?/g, '').toLowerCase();
var username = document.getElementById("username").value;
document.getElementById("displaymsg").innerHTML = "<b>Variable name:</b> " + name +"<br> <b>Variable username:</b> " + username;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment