<p>
<input type="text" value="" name="user_name" id="user_name" />
<span style="padding-left:10px;"><input type="button" value="show" onclick="showValue()" /></span>
</p>
<p id="text"></p>
function showValue() {
var user_name = document.getElementById("user_name");
var text = document.getElementById("text");
if (user_name.value == "") {
alert("Please input some words");
user_name.focus()
} else {
text.innerHTML = user_name.value;
text.setAttribute("class", "text")
}
}
var text = document.createElement("div");
text.appendChild(user_name.value);
document.body.appendChild(text);