提交翡翠表 [英] Submit Jade form

查看:94
本文介绍了提交翡翠表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下Jade表单模板有什么错误?我无法提交值.

What is the error with the following Jade form template? I can't get it to submit values.

 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')  

推荐答案

问题是因为您没有为任何输入字段指定名称.

The problem is because you haven't given any of the input fields a name.

app.post('/signup', function(req,res){
  console.log(req.body);
})

返回: {}

如果将表单编辑为以下内容:

If you edit the form to the following:

 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')

输入一些数据后,

app.post('/signup', function(req,res){
  console.log(req.body);
})

返回:

{ email: 'testing@fake.com',
  password: 'asdf',
  password2: 'asdf' }

这篇关于提交翡翠表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆