Last active
April 29, 2020 04:34
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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