title: How to Create a text captcha using java script in html form
body: <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;form action="Send_Contact_Us.php" method="post" onSubmit="return checkform(this);"&gt;
              &lt;label&gt;Name&lt;/label&gt;
              &lt;input name="name" type="text" required="required" /&gt;
              &lt;label&gt;Email&lt;/label&gt;
              &lt;input name="mail" type="email" required="required" /&gt;
              &lt;label&gt;Phone&lt;/label&gt;
              &lt;input type="text" name="phone" pattern="[789][0-9]{9}" required="required" /&gt;
              &lt;label&gt;Comments&lt;/label&gt;
              &lt;textarea name="comment" rows="3" cols="20" required="required"&gt;&lt;/textarea&gt;
              &lt;label for="code"&gt;Write code below &lt;span id="txtCaptchaDiv" style="color:#F00"&gt;&lt;/span&gt;
                  &lt;!-- this is where the script will place the generated code --&gt;
                  &lt;br/&gt;
                  &lt;input type="hidden" id="txtCaptcha" /&gt;
              &lt;/label&gt;
              &lt;input type="text" name="txtInput" id="txtInput" size="30" onfocus="validatePass(document.getElementById('txtCaptcha'), this);" oninput="validatePass(document.getElementById('txtCaptcha'), this);" /&gt;
              &lt;input type="submit" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the form code I want to generate a code above the text field using JavaScript.</p>