【发布时间】:2016-09-27 04:36:28
【问题描述】:
我的表单在表格中,我尝试在输入空间旁边写下表单验证的错误消息。 (我放在第三栏)
问题在于 form_error() 函数使表格中的行之间的行高更大。我应该怎么做?因为如果我使用 CSS,它会使“发生错误消息之前的行高”错误。按钮提交前后的if-else需要写吗?
<table>
<tr>
<td>Username : </td>
<td><input type="text" name="username" value="<?php echo set_value('username'); ?>"/></td>
<?php
if($this->input->post("btn") == null)
{
echo "<td><span style='font-size: 10px;color:red'>ขั้นต่ำ 6 ตัวอักษร</span></td>";
}
else
{
echo "<td><span style='font-size:10px;color:red;'>" . form_error('username') ."</span></td>";
}
?>
</tr>
<tr>
<td>Password : </td>
<td><input type="password" name="pass" value=""/></td>
<?php
if($this->input->post("btn") == null)
{
echo "<td><span style='font-size: 10px;color:red'>ขั้นต่ำ 6 ตัวอักษร</span></td>";
}
else
{
echo "<td><span style='font-size:10px;color:red;'>" . form_error('pass') ."</span></td>";
}
?>
</tr>
<tr>
<td>ยืนยัน Password : </td>
<td><input type="password" name="pass_confirm" value=""/></td>
<td><span style="font-size:10px;color:red;"><?php echo form_error('pass_confirm');?></span></td>
</tr>
<tr>
<td>Email : </td>
<td><input type="text" name="email" value="<?php echo set_value('email'); ?>"/></td>
<td><span style="font-size:10px;color:red;"><?php echo form_error('email');?></span></td>
</tr>
<tr>
<td colspan="2"><span style="font-size: 10px;color:red;">กรุณากรอกเบอร์มือถือ เพื่อรับ Code ยืนยันการสมัคร (ตัวอย่างเบอร์มือถือ 08xxxxxxxx)</span></td>
</tr>
<tr>
<td>เบอร์มือถือ : </td>
<td><input type="text" name="phone" value="<?php echo set_value('phone'); ?>"/></td>
<td><span style="font-size:10px;color:red;"><?php echo form_error('phone');?></span></td>
</tr>
<tr>
<td>กรอกรหัสภาพ :</td>
<td>
<?php echo $captcha['image']; ?>
<br>
<input type="text" autocomplete="off" name="userCaptcha" placeholder="Enter above text" value="<?php if(!empty($userCaptcha)){ echo $userCaptcha;} ?>" />
<?php echo form_error('userCaptcha','<p style="font-size:10px;color:red">','</p>'); ?>
</td>
</tr>
</table>
【问题讨论】:
标签: php html css codeigniter