0
 var trans = { 
     amount: $('#container input:first-child').val(),
     note: $('#container input:last-child').val()
    };  // javascript

 trans =  {
     "amount":"",
     "note":"",
 }  // json 

$trans = $this->input->post('trans');
$t = json_decode($trans);

$amount = $t->amount;
$note = $t->note;

$this->form_validation->set_rules('amount', 'Amount', 'required');

错误是

  Call to a member function set_rules() on a non-object in......

你如何验证一个 json 对象?

4

1 回答 1

0

尝试form_validation在构造函数中加载库

function __construct() {
    parent::__construct();
    $this->load->library('form_validation');
}    
于 2013-01-15T09:22:59.070 回答