我的表单中有三个切换按钮,我希望用户可以打开一个按钮,其他按钮会自动关闭.我不想在我的表单中使用典型的单选按钮.我从以下网址获得了切换按钮:http://www.w3schools.com/howto/howto_css_switch.asp
我的HTML是:
<!-- Rectangular switch -->
<label class="switch">
<input type="checkbox">
<div class="slider"></div>
</label>
<!-- Rounded switch -->
<label class="switch">
<input type="checkbox">
<div class="slider round"></div>
</label>
Run Code Online (Sandbox Code Playgroud)
我的css是:
<style type="text/css">
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: …Run Code Online (Sandbox Code Playgroud) 我正在验证 codeigniter 中的表单。如果用户没有正确填写表单,则页面不应重定向到任何其他页面,而是在每个输入字段上显示错误。这是我的表单代码:
<?php echo $this->session->flashdata('errors');?>
<form action="<?php echo base_url() ?>detail/travel" method="post">
<input type="text" name="departure">
<input type="text" name="destination">
<input type="text" name="name">
<input type="text" name="cell">
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的方法代码:
function search_travel(){
if($_POST){
$config = array(
array(
'field'=>'departure',
'label'=>'departure',
'rules'=>'trim|required|alpha'
),
array(
'field'=>'destination',
'label'=>'destination',
'rules'=>'trim|required|alpha'
),
array(
'field'=>'name',
'label'=>'name',
'rules'=>'trim|required|alpha'
),
array(
'field'=>'cell',
'label'=>'cell no',
'rules'=>'trim|required'
)
);
$this->load->library('form_validation');
$this->load->helper(array('form', 'url'));
$this->form_validation->set_rules($config);
if($this->form_validation->run() == FALSE){
$this->session->set_flashdata('errors', validation_errors());
redirect(base_url());
}
}
Run Code Online (Sandbox Code Playgroud)
}
问题是通过使用 set_flashdata 我不能使用 form_error 函数和 set_value 函数。这个问题有没有其他解决办法???