-1

In this my textboxes are generated by using JavaScript.In my controller I place the code for CodeIgniter validation. But I am confused about how to put the

           <?php echo form_error(); ?>

how to append this in javascript

                                     <div id='exp_error'> 
                                     <?php echo validation_errors(); ?> 
                                      </div> 

but this message displayed in all places..I want only in my link

script

          <input name="exp_amount_'+unqid1+'" id="id_'+unqid1+'" type="text" '+
        'class="form-control" placeholder="Enter '+name+' expense amount" style="margin-right:20px;" required>'
        +'<input name="comment_'+unqid1+'" type="text" id="comment"  class="form-con" placeholder="Comments" style="margin-right:20px;" required ></div >' ;

controller

          $this->form_validation->set_rules('exp_amount_'.$required_id, 'Expense Amount', 'required|numeric');
        $this->form_validation->set_rules('comment_'.$required_id, 'Comments', 'required');
0

1 Answer 1

2

The Javascript has to be in the "view" that is corresponding to the Action in the controller, otherwise this wont work. Because the PHP part is not getting executed in the server. It's getting generated in the client side and so, it's taking as plain HTML. Hope u understood my point.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.