Im node nodes, expressjs and z I am using In the route: in The above code works I want to keep the input value in the form so that users do not type it. how? Thanks You can revert the value to the rendered view directly and Input tags can be placed on each other. and put in jade template or or Pre> It depends on your personal style. It is better to define values like express-validator to validate a form.
req.assert ('firstname', 'name is required') notEmpty () .; Req.assert ('Last name', 'name is required'). NotEmpty (); Req.assert ('email', 'a valid email is required'). IsEmail (); Var Errors = req.validationErrors (); .... if (errors) {res.render ('user / new', {errors: errors}); }
Z , to display the error:
- if (errors) div.alert .alert-ral ul - errors in every error li = error.msg
input # name (type = "text", name = "name", value = "?")
if (errors) {res.render ('users / new', {errors: errors, first name first name, ...}); }
input # name (type = "text", name = "firstname", value = "# {firstName} Input # name (type = "text", name = "firstname", value = first name)
person.first ,
person.last and
Person.email , because you only You can put
person in the view of your code.
No comments:
Post a Comment