router.post('/submit', function(req,res,next) { //check validity req.check('email', 'Invalid email address').isEmail(); req.check('password', 'Password is invalid').isLength({ min: 4}).equals(req.body.confirmPassword); var errors = req.getValidationResult(); if (errors) { req.session.errors = errors; } else { req.session.success = true; } res.redirect('/'); });
req.checkBody('username', 'Username is required').notEmpty(); req.checkBody('password', 'Password is required').notEmpty(); req.checkBody('password2', 'Passwords do not match').equals(req.body.password);
req.checkBody('password', 'Password is required.').notEmpty(); req.checkBody('password', 'Password is invalid.').isLength({min:6}); req.checkBody('confirm-password', 'Password does not matched.').equals(req.body.password); req.checkBody('name', 'Name is required.').notEmpty(); req.checkBody('address', 'Address is required.').notEmpty();
req.checkBody('username', "username field is required").notEmpty(); req.checkBody('password', "password field is required").notEmpty(); req.checkBody('password2', "password does not match").equals(req.body.password);
req.checkBody('password', 'Passwords have to match').equals(req.body.verifyPassword); let invalidFieldErrors = req.validationErrors() if (invalidFieldErrors) {
req.checkBody('username','Username Field is Required').notEmpty(); req.checkBody('password','Password Field is Required').notEmpty(); req.checkBody('confirmPassword','Passwords do not Match').equals(req.body.password);
app.post("/submit", (req, res) => { req.check("email", "Invalid Email").isEmail(); // isMobilePhone // isEmail() // isPostalCode // isCurrency // isCreditCard req .check("password", "Invalid Password") .isLength({ min: 6 }) .equals(req.body.confPassword); const errors = req.validationErrors(); if (errors) { req.session.errors = errors; req.session.done = false; } else { req.session.done = true; } res.redirect("/"); });