-
-
Save emerleite/841414 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var form = require('express-form'); | |
validate = form.validator; | |
filter = form.filter; | |
/* setup express server here */ | |
app.get('/', function(req,res){ | |
form( | |
validate('foo').required(); | |
validate('bar').required('a placeholder text for bar', 'a customize error message here'); | |
)(req, res) | |
if(!req.form.isValid){ | |
//error handling | |
console.log(req.form.errors); | |
} | |
else{ | |
//submit data handling | |
console.log(req.form.foo); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment