Bootstrap Modal With Codeigniter Form Validation
Error_validation
is a feature that CI provides.
You can only use error_validation
of code igniter when the page is submitted hence, the bootstrap modal is automatically closed because the page is getting submitted.
If you want to perform a form validation on a modal, it is better you use AJAX
If you want to show the error message above the form_open,just make a blank div like:
<div class='error_msg'></div>
and with jquery:
$(function(){$('#form_id').submit(function(event){event.preventDefault();var custemail = $('#email_id').val();var custname = $('#name').val();$.ajax({ type: 'POST', url: your controller path, data: { 'name': custname, 'email': custemail }, dataType: 'html', success: function(results){ if(something not as you expected){ $('.error_msg').html('error msg'); return false; } } });});});