title: After JavaScript alert value is null
body: <p>When I am doing JavaScript alert after that value is been null from the input text. But I want that after the JavaScript alert value should be available in the input text.</p>
  
  <p>Here is my code</p>
  
  <pre><code>&lt;script&gt;
  
          function validateform() {
  
              var email = $('#txt_emailID').val();
              if (email == null || email == "") {
                  alert("Email Should Be Complusory");
                  return false;
              }
              var atposition = email.indexOf("@");
              var dotposition = email.lastIndexOf(".");
              if (atposition &lt; 1 || dotposition &lt; atposition + 2 || dotposition + 2 &gt;= email.length) {
                  alert("Please enter a valid e-mail address...!!!");
                                  return false;
              }
          }
  
      &lt;/script&gt;
  
  &lt;label for="fname"&gt;Name&lt;/label&gt;
          &lt;input type="text" id="txt_name" name="txt_name" placeholder="Your Name.." /&gt;
  
          &lt;label for="lname"&gt;EmailID&lt;/label&gt;
          &lt;input type="text" id="txt_emailID" name="email" placeholder="Your EmailID.." /&gt;
  
          &lt;label for="lname"&gt;Subject&lt;/label&gt;
          &lt;input type="text" id="txt_subject" name="txt_subject" placeholder="Your Subject.." /&gt;
  
          &lt;input type="submit" id="submit_mail" value="Send" /&gt;
  
          &lt;script&gt;
              $(function () {
                  $(document).on("click", "#submit_mail", function () {
                      if (validateform() == false) {
                          document.getElementById("txt_name").value = $('#txt_name').val();
                          document.getElementById("txt_subject").value = $('#txt_subject').val();
  
                      }
                      else {
  
                      }
                  });
              });
  </code></pre>
  
  <p>I don't know where I am getting a problem.</p>