form和table制作注册表单

//form和table制作的提交服务器表单

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Insert title here</title>
 </head>
 <body>
 <fieldset>
   <legend>注 册</legend >
 
   <form action="
http://192.168.1.100:9999" method="post">
 <table border="1" width="50%" height="300" align="center" cellspacing="0">
    <tr>
      <td>用户名:</td>
      <td><input type="text" name="username"></td>
    </tr>
   
    <tr>
      <td>密 码:</td>
      <td><input type="password" name="password"></td>
    </tr>
   
    <tr>
      <td>性 别:</td>
     <td>
       <input type="radio" name="gender" value="male" checked="checked">男
       <input type="radio" name="gender" value="female">女
       </td>
    </tr>
    <tr>
      <td>兴 趣:</td>
      <td>
       <input type="checkbox" name="interest" value="basketball" checked="checked">篮球
       <input type="checkbox" name="interest" value="game">游戏
       <input type="checkbox" name="interest" value="net">上网
      </td>
    </tr>
   
    <tr>
      <td>城 市:</td>
       <td>
        <select name="city">
          <option value="">-请选着城市-</option>
          <option value="bj">北京</option>
          <option value="hn">河南</option>
          <option value="zmd">驻马店</option>
        </select>
       </td>
    </tr>
    <tr>
      <td>自我介绍</td>
      <td>
        <textarea rows="5" cols="60"></textarea>
      </td>
    </tr>
    <tr>
      <td>头 像:</td>
      <td>
        <input type="file" name="photo">
      </td>
    </tr>
   
    <tr align="center">
      <td colspan="2">
        <input type="submit" value="注册">
        <input type="reset" value="重填">
      </td>
    </tr>
 </table>
 </form>
 
 </fieldset>
 </body>
</html>

根据提供的引用内容,ant-design-vue可以通过内置的Form组件和Table组件实现表格内部字段验证功能。具体步骤如下: 1. 在表格中添加需要验证的字段,例如下面的代码中的name和age字段: ```html <a-form :form="form"> <a-form-item label="Name" :rules="[{ required: true, message: 'Please input name' }]"> <a-input v-decorator="['name']" /> </a-form-item> <a-form-item label="Age" :rules="[{ required: true, message: 'Please input age' }]"> <a-input-number v-decorator="['age']" /> </a-form-item> </a-form> <a-table :columns="columns" :dataSource="dataSource" :pagination="false" /> ``` 2. 在表格中添加操作列,例如下面的代码中的操作列包含了编辑和删除按钮: ```html <a-table :columns="columns" :dataSource="dataSource" :pagination="false"> <template #action="text, record"> <a-button @click="edit(record)">Edit</a-button> <a-button @click="delete(record)">Delete</a-button> </template> </a-table> ``` 3. 在编辑操作中打开表,并将当前行的数据绑定到表中: ```javascript edit(record) { this.form.setFieldsValue(record); this.editingKey = record.key; } ``` 4. 在表中添加保存按钮,并在点击保存按钮时进行表验证和数据更新: ```html <a-form :form="form"> <a-form-item label="Name" :rules="[{ required: true, message: 'Please input name' }]"> <a-input v-decorator="['name']" /> </a-form-item> <a-form-item label="Age" :rules="[{ required: true, message: 'Please input age' }]"> <a-input-number v-decorator="['age']" /> </a-form-item> <a-form-item> <a-button type="primary" @click="save">Save</a-button> </a-form-item> </a-form> ``` ```javascript save() { this.form.validateFields((err, values) => { if (!err) { const newData = [...this.dataSource]; const index = newData.findIndex((item) => this.editingKey === item.key); if (index > -1) { const item = newData[index]; newData.splice(index, 1, { ...item, ...values }); this.dataSource = newData; this.editingKey = ''; } else { newData.push(values); this.dataSource = newData; this.editingKey = ''; } } }); } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值