Password confirmation(form validation) from server-side to client side

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.

<form action="/new" method="POST">Name:
  <input type="text" name="name" class="name"/><br/>Phone number:
  <input type="text" name="phone" class="phone"/><br/>email:
  <input type="email" name="email" class="email"/><br/>Password:
  <input type="password" id="p1" name="pass" class="pass"/><br/>Confirm password:
  <input type="password" id="p2" name="confirm" class="confirm"/><br/>
  <input type="submit" value="Submit" onclick="return validateForm()"/>

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:)

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;

also here is my registration server side code:



var Schema = new mongoose.Schema({
  name    : String,
  phone: String,
  email : String,
  pass : String,
  confirm : String

var user = mongoose.model('emp', Schema);'/new', function(req, res){

  new user({
    name :,
    pass: req.body.pass,
    confirm: req.body.confirm   
  }).save(function(err, doc){
    if(err) res.json(err);
    else    res.send('Successfully inserted!');



For validating email you should use-


For the validation of Password and Confirm Password you should use-

req.assert('confirm', 'Password and Confirm Password should be same.').equals(req.body.pass);
var mappedErrors = req.validationErrors(true);

Need Your Help

Add a GMGridView to a subview so that it doesn't take all screen

ios objective-c gridview gmgridview

I am trying to add a GMGridView to a subview in my nib file, but I can't seem to figure out how to do this because GMGridView keeps taking up all the space in my nib generated view, and covers ever...