我有一个像这样的基本 HTML 表单。提交后,它会检查空字段并提醒用户这两个字段都是必需的。警报后,用户被重定向到同一页面,但文本输入大小减小。PHP“回显”后如何保持相同的宽度、高度?
屏幕截图 1:
截图二:
截图 3:
控制器:
function validate_user_pass() {
$this->load->library('form_validation');
$this->form_validation->set_rules('username','Email', 'required|max_length[30]');
$this->form_validation->set_rules('password','Password', 'required|max_length[32]');
if ($this->form_validation->run() == FALSE ) {
//$this->load->view('login_error');
echo '<script type="text/javascript">alert("Required fields are empty!");</script>';
$this->index();
}
else {
$this->verify();
}
}
看法:
<?php echo form_open('login/validate_user_pass'); ?>
<div class="login">
<div class="login-screen">
<div class="login-icon">
<img src="<?php echo base_url(); ?>assets/images/1374606542_newsstand_ios7_ios_7.png" alt="logo">
<h4>Hotel<small>Management System</small></h4>
</div>
<div class="login-form">
<img src="<?php echo base_url(); ?>assets/ico/logo_small.png" alt="logo">
<div class="control-group">
<input type="text" class="login-field" name="username" value="<?php echo set_value('username'); ?>" placeholder="Enter username" id="login-name">
</div>
<div class="control-group">
<input type="password" class="login-field" name="password" value="" placeholder="Password" id="login-pass">
</div>
<input type="submit" class="btn btn-primary" value="Login">
</div>
</div>
</div>
<?php echo form_close(); ?>