title: How to show error message on each input type field in nodejs using express-validator
body: <pre><code>I am begginer in nodejs and I am using express-validator library to validate form.
  </code></pre>
  
  <p>I want to display error message seprately to each input type field,
   not group wise.
   Currently my code shows the error in group like </p>
  
  <pre><code>Name is required!
  Email is required!
  Email is wrong!
  Mobile is required!
  </code></pre>
  
  <p>========================================================================</p>
  
  <p><strong>Controller Code</strong></p>
  
  <pre><code>employeeController.saveEmployee = function(req,res){
      var employeeData = req.body;
      // Start Validation
      req.checkBody('employeeName','Name is required!').notEmpty();
      req.checkBody('employeeEmail','Email is required!').notEmpty();
      req.checkBody('employeeEmail','Email is wrong!').isEmail();
      req.checkBody('employeeMobile','Mobile is required!').notEmpty();
  
      req.sanitize('employeeName').trim();
      req.sanitize('employeeName').escape();
      // End Validation
      var errors = req.validationErrors();
      console.log(errors);
      if(!errors){
          var employee = new Employee({
              name : req.body.employeeName,
              email : req.body.employeeEmail,
              mobile : req.body.employeemobile,
          });
          employee.save(function(err){
              if(err){
                  throw err;
              }
              console.log('User inserted successfully');
              res.redirect('/employee-list');
          });
      }else{
          console.log(employeeData.employeeName);
          res.render('employee/add-employee',{
              errors : errors,
              employeeData : employeeData
          });
      }
  };
  </code></pre>
  
  <p><strong>View template</strong> </p>
  
  <pre><code>&lt;div class="col-md-12"&gt;
      &lt;div class="box box-primary"&gt;
          &lt;div class="box-header with-border"&gt;
              &lt;h3 class="box-title"&gt;Add Employee Profile&lt;/h3&gt;
              &lt;h5 class='text-aqua pull-right' style='margin-top: 0px;'&gt;
                  &lt;a href='javascript:void(0);' onclick='' class="btn btn-sm btn-info btn-flat"&gt;&lt;i class="fa fa-backward"&gt;&lt;/i&gt;&amp;nbsp;Back&lt;/a&gt;
              &lt;/h5&gt;
          &lt;/div&gt;
          &lt;p&gt;
              &lt;% if(errors){ %&gt;
                  &lt;ul&gt;
                  &lt;% for(var i = 0; i &lt; errors.length; i++){ %&gt;
                      &lt;li&gt; &lt;%= errors[i].msg %&gt; &lt;/li&gt;
                  &lt;% } %&gt;
                  &lt;/ul&gt;
               &lt;% } %&gt;
          &lt;/p&gt;
          &lt;!-- form start --&gt;
          &lt;form method = 'post' action = '/save-employee'&gt;
              &lt;div class="box-body"&gt;
                  &lt;div class="form-group col-md-4"&gt;
                      &lt;label&gt;Name&lt;/label&gt;
                      &lt;div class='input-group'&gt;
                          &lt;span class="input-group-addon"&gt;&lt;i class="fa fa-pencil"&gt;&lt;/i&gt;&lt;/span&gt;
                          &lt;input type='text' name='employeeName' id='employeeName' value='&lt;%= employeeData.employeeName %&gt;' class='form-control' placeholder='Employee Name'&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
                  &lt;div class="form-group col-md-4"&gt;
                      &lt;label&gt;Email&lt;/label&gt;
                      &lt;div class='input-group'&gt;
                          &lt;span class="input-group-addon"&gt;&lt;i class="fa fa-pencil"&gt;&lt;/i&gt;&lt;/span&gt; 
                          &lt;input type='text' name='employeeEmail' id='employeeEmail' value='&lt;%= employeeData.employeeEmail %&gt;' class='form-control' placeholder='Employee Email'&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
                  &lt;div class="form-group col-md-4"&gt;
                      &lt;label&gt;Mobile&lt;/label&gt;
                      &lt;div class='input-group'&gt;
                          &lt;span class="input-group-addon"&gt;&lt;i class="fa fa-pencil"&gt;&lt;/i&gt;&lt;/span&gt; 
                          &lt;input type='text' name='employeeMobile' id='employeeMobile' value='&lt;%= employeeData.employeeMobile %&gt;' class='form-control' placeholder='Employee Mobile'&gt;
                      &lt;/div&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="callout" id='message-container' style='display:none;'&gt;&lt;/div&gt;
              &lt;div class="box-footer"&gt;
                  &lt;button type='submit' name='saveEmployeeProfile' class='btn btn-primary'&gt;Save&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>