Quelle est l'erreur avec le modèle de formulaire Jade suivant? Je n'arrive pas à lui soumettre des valeurs.
div
form(action='/signup',method='post')
div(data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='email') email
input(id='email',type='text',value='',placeholder='@')
div#passworddiv(data-role='fieldcontain')
fieldset(data-role='controlgroup
label(for='password') password
input(id='password',type='password',value='',placeholder='')
div(id='hiddendiv',data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='hidden_password') password
input(id='hidden_password',type='text',value='',placeholder='')
div(data-role='fieldcontain')
fieldset(data-type='vertical', data-role='controlgroup')
label(for='showpass') show password
input(id='showpass',type='checkbox')
div(data-role='fieldcontain')
input(type='submit',value='Sign Up',data-transition='fade', data-theme='c')
Le problème est que vous n'avez donné aucun nom aux champs de saisie.
app.post('/signup', function(req,res){
console.log(req.body);
})
Retour: {}
Si vous modifiez le formulaire comme suit:
div
form(action='/signup',method='post')
div(data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='email') email
input(id='email',type='text',value='',placeholder='@',name='email')
div#passworddiv(data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='password') password
input(id='password',type='password',value='',placeholder='',name='password')
div(id='hiddendiv',data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='hidden_password') password
input(id='hidden_password',type='text',value='',placeholder='',name='password2')
div(data-role='fieldcontain')
fieldset(data-type='vertical', data-role='controlgroup')
label(for='showpass') show password
input(id='showpass',type='checkbox')
div(data-role='fieldcontain')
input(type='submit',value='Sign Up',data-transition='fade', data-theme='c')
Après avoir saisi certaines données,
app.post('/signup', function(req,res){
console.log(req.body);
})
retour:
{ email: '[email protected]',
password: 'asdf',
password2: 'asdf' }