title: How to clear form fields (input, textarea, select and radio) in javascript or jquery
body: <p>I have simple html form </p>
  
  <pre><code> &lt;form id="formreg" name="formreg" method="post"  enctype="multipart/form-data" style="margin:0; padding:0; float:left;" onsubmit="return CommonFunction(this);"&gt;   
  
  
  
    &lt;table border="1" cellpadding="2" cellspacing="1" style="border-collapse:collapse; font:12px Verdana, Arial, Helvetica, sans-serif;"&gt;
  
    &lt;tr&gt;
    &lt;td align="left"&gt; First Name : &lt;/td&gt;
    &lt;td&gt; &lt;input type="text" name="firstname" value=""/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
  
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Last Name : &lt;/td&gt;
    &lt;td&gt; &lt;input type="text" name="lname" value=""/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Email : &lt;/td&gt;
    &lt;td&gt; &lt;input type="text" name="useremail" value=""/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Contact No : &lt;/td&gt;
    &lt;td&gt; &lt;input type="text" name="usercontact" value=""/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Designation : &lt;/td&gt;
    &lt;td&gt; &lt;input type="text" name="designation" value="" size="20" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Gender : &lt;/td&gt;
    &lt;td&gt; 
    &lt;input type="radio" name="gender" value="Male" /&gt; Male &amp;nbsp;&amp;nbsp;&lt;input type="radio" name="gender" value="Female" /&gt; Female
    &lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Country : &lt;/td&gt;
    &lt;td&gt; 
  
    &lt;select name="country"&gt;
  
       &lt;option value="India"&gt;India&lt;/option&gt;
       &lt;option value="USA"&gt;USA&lt;/option&gt;
       &lt;option value="UK"&gt;UK&lt;/option&gt;
    &lt;/select&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
  
  
  
    &lt;tr&gt;
    &lt;td align="left"&gt; Message/Comment: &lt;/td&gt;
    &lt;td&gt; &lt;textarea name="message" cols="20" rows="5"&gt;&lt;/textarea&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;tr&gt;
    &lt;td align="left" colspan="2"&gt; &lt;input type="submit" name="Sub" value="Insert" /&gt; &amp;nbsp; &lt;input type="reset"  value="Reset" /&gt; &lt;/td&gt;
    &lt;/tr&gt;
  
    &lt;/table&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>With form fields (input, text-area, select-box and radio button).</p>
  
  <p>I need java-script function or jquery code to clear all form fields . I cannot use reset button because on form onsubmit event I'm calling a function called CommonFunction() which post all form fields using jQuery.ajax. The problem is when i submit the form data get posted successfully but the form fields doesnt clear automatically since I'm submitting form using jQuery.ajax</p>
  
  <p>Once the data is submitted then i want form to be clear .</p>
  
  <p>Need help</p>