[eluser]BrandonDurham[/eluser]
I know it sounds crazy, but hear me out.
I'm building a site for a client in CI that used to exist in HTML with JS form validation. They're very happy with the way it's working except they prefer the old-school javascript alert boxes letting the user know they've done something wrong in the form. I want to be able to tie it in directly with CI's validation class. I'm currently doing this in my view:
Code:
<?if ($this->validation->error_string) { ?>
msg = '<?=$this->validation->first_name_error; ?>';
ShowErrors(msg);
<? } ?>
... and this JS function is in the head:
Code:
function ShowErrors(str)
{
msg = "______________________________________________________\n\n";
msg += "The form was not submitted because of the following error(s).\n";
msg += "Please correct these error(s) and re-submit.\n";
msg += "______________________________________________________\n\n";
msg += str;
alert(msg);
}
This works fine, however the form is approximately 20 fields long and I don't really want to add each field's error individually. Is there a way I can pass the "ShowErrors" JS function the $this->validation->error_string and have it cycle through all errors?
I appreciate any help.
Thanks!