How about using AJAX?
$("form").submit(function(e) {
e.preventDefault();
$.post("<?php echo base_url(); ?>regex_check", { username: $("#username").val() }, function (data) {
alert(data);
});
The regex_check function would have a typical regex check in it, like
function regex_check(){
$this->get->post('username');
if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-] +\.[a-zA-Z.]{2,5}$', $username)){
return TRUE;}else{return FALSE;}
}
You would only allow successful submission of form if all data is validated.
These code snippets should help you on the track to validating the data.