Nodejs Form Validation

Source: Internet
Author: User

Create an express connection

var exp = require (' xepress '),

HTTP = require (' http ');

Initializing the Exprerss module

var app = exp ();

Configure Port Numbers

App.set (' post ', 8080);

Set a static path

App.use (exp.static (__dirname + "folder path and name of the storage foreground data"));

Set icon

App.use (Exp.favicon ());

Error log output

App.use (Exp.logger ("dev"));

Allow overwrite

App.use (Exp.bodyparser ());

App.use (Exp.methodoverride ());

Output error Log

if (' Development ' ==app.get (' env ')) {

App.use (Exp.errorhandler);

}

Create a service

Http.createserver (APP). Listen (App.get (' post '), function () {

Console.log (' Express + post ' + app.get (' post '))

})

Form Connection

App.post (' connection properties ' of the form, function (req,res) {

var variable name = [req.body. Name,req.body of input under form. Name of input under form];

var variable name (con) = variable name of the background data path (obtained at the beginning of the declaration). The variable name of the exported function ([req.body. Name,req.body of input under form. Name],function of input under form (E,R,F) {

if (!e) {

if (r.length) {

redirect

Res.redirect (' HTML ' of the Web page that needs to be opened);

}

}

})

})

Nodejs Form Validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.