Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
        <input id="name" type="text" placeholder="Slogan here...">
        <input id="submit" type="submit" value="Generate" onclick="formSubmit()">
  <div id="nameContent"></div>
  <div id="errormsg"></div>
</body>
</html>
 
function formSubmit() {
  var formName, formError, nameSentence;
  formError = document.getElementById("errormsg");
  formName = document.getElementById("name");
  nameSentence = document.getElementById("nameContent");
  if(formName) {
    if (formName.value === "") {
      formError.innerHTML = "Put your name in!";
    } else if (formName.value.length > 20) {
      errormsg.innerHTML = "Max. 20 characters";
    } else {
      nameSentence.innerHTML = formName.value ;
    }
  }
}
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers