dongxiejie9387 2015-07-16 02:15 采纳率: 100%
浏览 55

在CodeIgniter中的FancyBox中显示验证错误

I have a FancyBox in the home page which contains a registration form.

Validation is working fine.

Currently, I have to manually click on the FancyBox to see the error messages on that form.

Here's the code which reloads the page. But I want it to show the FancyBox as soon as the page loads. It is just a simple validation check.

if ($this->form_validation->run() == FALSE)
{
    $this->load->view('valform');
}
else
{
    $this->load->view('formsubmit');
}

So what I want is to show that FancyBox with validation errors.

Validation is working, as it is shown in the FancyBox; when the page reloads I have to manually click on that FancyBox to see the validation errors. Is there a way I can store it in a session and use that instead? If yes, how? Or how can I use ajax for this, and get validation errors to show on the FancyBox?

  • 写回答

1条回答 默认 最新

  • dsozqcx9668 2015-07-16 04:01
    关注

    You can see the example below. Try to implement it with ajax and jquery.

    public function ajax_()
    {
      $this->form_validation->set_rules('par','name of something','required');
    
      if($this->form_validation->run()!=TRUE)
      {
        echo json_encode(array('result'=>'error','msg'=>validation_errors()));
      }
      else
      {
        echo json_encode(array('result'=>'success','msg'=>'success'));
      }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)