title: Password confirmation(form validation) from server-side to client side
body: <p>I have Express.js server. Running in node.js. Using javascript server side language. There I have signup sipmle form, register new user and save users in mongoDb. POST method. </p>
  
  <pre><code>&lt;form action="/new" method="POST"&gt;Name:
    &lt;input type="text" name="name" class="name"/&gt;&lt;br/&gt;Phone number:
    &lt;input type="text" name="phone" class="phone"/&gt;&lt;br/&gt;email:
    &lt;input type="email" name="email" class="email"/&gt;&lt;br/&gt;Password:
    &lt;input type="password" id="p1" name="pass" class="pass"/&gt;&lt;br/&gt;Confirm password:
    &lt;input type="password" id="p2" name="confirm" class="confirm"/&gt;&lt;br/&gt;
    &lt;input type="submit" value="Submit" onclick="return validateForm()"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Need to create input validation(actualy it's "Password confirm" and "Email")Also need to use "regex". How I can realize this method?I created input data validation on client-side.It's works.Maybe I just need put this code in the server? Searching in google don't give me expected results... I saw many validation methods validator.js but not finde detailed code...Thank you for helping:)</p>
  
  <pre><code>&lt;script&gt;
  function validateForm (event) {
  var p1 = document.getElementById('p1');
  var p2 = document.getElementById('p2');
  if (p1.value !== p2.value) {
  alert('Password check!');
  return false;
  }
  // check email
  var email = document.getElementById('email');
  // regex
  var email_regexp = /[0-9a-zа-я_A-ZА-Я]+@[0-9a-zа-я_A-ZА-Я^.]+\.[a-zа-яА-ЯA-Z]{2,4}/i;
  if (!email_regexp.test(email.value)) {
  alert('Check email');
  return false;
  }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>also here is my registration server side code: </p>
  
  <pre><code> app.use(bodyParser());
  
  mongoose.connect('mongodb://localhost/test');
  
  var Schema = new mongoose.Schema({
    name    : String,
    phone: String,
    email : String,
    pass : String,
    confirm : String
  });
  
  var user = mongoose.model('emp', Schema);
  
  app.post('/new', function(req, res){
  
    new user({
      name : req.body.name,
      phone: req.body.phone,
      email: req.body.email,
      pass: req.body.pass,
      confirm: req.body.confirm   
    }).save(function(err, doc){
      console.log(user); 
      if(err) res.json(err);
      else    res.send('Successfully inserted!');
  
    });
  });
  </code></pre>