在form_validation中的set_rules之后,可以这样:
$this->form_validation->set_rules('empfact', 'Nome da Empresa','trim|required|xss_clean');
此操作会修改我的网页布局吗?无论如何这是可能的吗?
因为我遇到问题并且在此操作之后出现问题(set_rules)。
问题是:在我提交表单和set_rules之后,我的网页加载了页面顶部的空格,高度为+/- 10px。
另外:在IE中(仅在IE中)执行此操作后,我的网页加载时没有一些图像并向左对齐。
有什么想法吗?
表单控制器
<?php
class Form extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|matches[emailconf]|callback_value_email|xss_clean');
$this->form_validation->set_rules('emailconf', 'Confirmação de Email', 'trim|required|xss_clean');
$this->form_validation->set_rules('passwd', 'Password', 'trim|required|matches[passconf]|xss_clean');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required|xss_clean');
$this->form_validation->set_rules('empfact', 'Nome da Empresa', 'trim|required|xss_clean');
$this->form_validation->set_rules('contr', 'Nº Contribuinte', 'trim|required|xss_clean');
$this->form_validation->set_rules('nome', 'Nome', 'trim|required|xss_clean');
$this->form_validation->set_rules('apelido', 'Apelido', 'trim|required|xss_clean');
$this->form_validation->set_rules('morada', 'Morada', 'trim|required|xss_clean');
$this->form_validation->set_rules('codpostal', 'Código Postal', 'trim|required|xss_clean');
$this->form_validation->set_rules('localidade', 'Localidade', 'trim|required|xss_clean');
$this->form_validation->set_rules('telefone', 'Telefone', 'trim|required|xss_clean');
$this->form_validation->set_rules('telemovel', 'Telemóvel', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('header');
$this->load->view('myform');
$this->load->view('footer');
}
else
{
$this->load->view('header');
$this->load->view('formsuccess');
$this->load->view('footer');
}
}
public function value_email($str)
{
$this->load->model('carfinder_model');
// Validate exists
$result = $this->carfinder_model->confirmExistence('email', $str);
// Now we verify the result
if(! $result)
{
return TRUE;
}
else
{
$this->form_validation->set_message('value_email', 'O e-mail escolhido já está registado');
return FALSE;
}
}
}
?>
myForm视图
<!-- content -->
<section id="content">
<div class="wrapper">
<div class="indent-bot-12">
<h2 class="indent-bot-2">Registe-se agora no CarFinder-PRO.pt</h2>
<ul class="list-box">
<li>
<h3 class="indent-bot-7">Para utilizar os serviços CarFinder-PRO.pt, é necessário registar-se. O registo permite-lhe aceder à listagem dos veículos, reservá-los e encomendá-los. O registo é rápido e gratuito.</h3>
<p class="indent-bot-15">*O registo é exclusivo a comerciantes profissionais. Após o registo a sua conta só será ativada depois de passar o processo de validação. Todos os campos são de preenchimento obrigatório.</p>
</li>
<?php if(validation_errors())
{
echo '<li>';
echo '<div class="val-errors">';
echo '<div class="val-image">';
echo '<img src="../../images/stopp.png" alt="" />';
echo '</div>';
echo '<div class="val-text">';
echo validation_errors();
echo '</div>';
echo '</div>';
echo '</li>';
}?>
<li>
<?php echo form_open('form'); ?>
<p class="indent-bot-15">*Dados de Acesso</p>
<b><label for="email"><?php if(form_error('email')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Email</label></b>
<input type="text" name="email" value="<?php if(! form_error('email')) { echo set_value('email'); } ?>" size="40" />
<br />
<b><label for="emailconf"><?php if(form_error('email')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Confirmar Email</label></b>
<input type="text" name="emailconf" value="<?php if(! form_error('email')) { echo set_value('emailconf'); } ?>" size="40" />
<br />
<!-- <h5>Username</h5>
<php echo form_error('username'); ?>
<input type="password" name="username" value="<php echo set_value('username'); ?>" onfocus='this.value="";' onblur='if (this.value=="") this.value = "E-mail:";' size="50" /> -->
<b><label for="passwd"><?php if(form_error('passwd')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Password</label></b>
<input type="password" name="passwd" value autocomplete="off" size="25" />
<br />
<b><label for="passconf"><?php if(form_error('passwd')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Confirmar Password</label></b>
<input type="password" name="passconf" value autocomplete="off" size="25" />
<br />
</li>
<li>
<p class="indent-bot-15">*Dados Pessoais</p>
<b><label for="empfact"><?php if(form_error('empfact')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Nome da Empresa</label></b>
<input type="text" name="empfact" value="<?php if(! form_error('empfact')) { echo set_value('empfact'); } ?>" size="40" />
<br />
<b><label for="contr"><?php if(form_error('contr')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Nº Contribuinte</label></b>
<input type="text" name="contr" value="<?php if(! form_error('contr')) { echo set_value('contr'); } ?>" size="25" />
<br />
<b><label for="nome"><?php if(form_error('nome')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Nome</label></b>
<input type="text" name="nome" value="<?php if(! form_error('nome')) { echo set_value('nome'); } ?>" size="40" />
<br />
<b><label for="apelido"><?php if(form_error('apelido')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Apelido</label></b>
<input type="text" name="apelido" value="<?php if(! form_error('apelido')) { echo set_value('apelido'); } ?>" size="40" />
<br />
<b><label for="morada"><?php if(form_error('morada')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Morada</label></b>
<input type="text" name="morada" value="<?php if(! form_error('morada')) { echo set_value('morada'); } ?>" size="40" />
<br />
<b><label for="codpostal"><?php if(form_error('codpostal')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Código Postal</label></b>
<input type="text" name="codpostal" value="<?php if(! form_error('codpostal')) { echo set_value('codpostal'); } ?>" size="40" />
<br />
<b><label for="localidade"><?php if(form_error('localidade')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Localidade</label></b>
<input type="text" name="localidade" value="<?php if(! form_error('localidade')) { echo set_value('localidade'); } ?>" size="40" />
<br />
<b><label for="telefone"><?php if(form_error('telefone')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Telefone</label></b>
<input type="text" name="telefone" value="<?php if(! form_error('telefone')) { echo set_value('telefone'); } ?>" size="25" />
<br />
<b><label for="telemovel"><?php if(form_error('telemovel')) { echo '<div class="imgset"><img src="../../images/markerred.jpg" alt="" /></div>'; } ?> Telemóvel</label></b>
<input type="text" name="telemovel" value="<?php if(! form_error('telemovel')) { echo set_value('telemovel'); } ?>" size="25" />
<br />
<br /><br />*Ao clicar no botão Registar, declara que aceita as <a href="#">Condições Gerais de Utilização</a> da CarFinder bem como os seus <a href="#">Termos e Condições</a>.
<br /><br />
<div><input class="button-registo" type="submit" value="Registar" /></div>
<br />
</form>
</li>
</ul>
</div>
</div>
答案 0 :(得分:1)
最后,我发现了问题。 这是一个非常愚蠢的问题,但是这个POST可能对将来的其他程序员有用。
我在NOTEPAD ++中选择以UTF-8(标准是ANSI)进行文本编码&lt; - 这就是问题所在。
现在一切正常,
所有人。
答案 1 :(得分:0)
也许你可以留下一个空的'div'来保存这样的视图中的错误:
<div class="container">
<?php echo form_error('empfact','<div class="error">','</div>'); ?>
</div>
答案 2 :(得分:0)
我相信你会在你的CSS中找到答案/问题。
您还根据表单(myform)是否经过验证来加载两个不同的视图。所以你实际上并没有在表单提交上重新加载,你正在加载一个新视图(formsuccess),并且可能引入了不同的元素嵌套,CSS等。
通过仅加载一个视图(myform)来调试页面。暂时关闭条件语句,并担心myform。 CodeIgniter中的表单验证可以通过一个视图完成。这就是用户手册建议那些内联php
函数调用的原因,我在你的标记中看到了这些函数。尝试让该页面正常工作。然后担心转储到“成功”页面。