I'm having a problem with a HTML form (name, e-mail, subject, message), I can't validate the form if it was completed correct or not. I want to call a javascript function when the form is submitted and alert if a field wasn't completed correct.
My problem is with the submit button, because my boss said that I must use he's own php function to insert a submit button. The php function looke like:
function normal_button($text, $width, $param = '', $class = 'button-blue')
{
$content = '<div class="'.$class.'" style="width:'.$width.'px;" '.$param.'>'.$text.'</div>';
return $content;
}
and how I call the function:
echo normal_button('Send it', '100', 'onclick="document.getElementById(\'emailForm\').submit();" ');
I tried to call the js function declaring the onSubmit="return checkForm(this)" in the <form action='email.php' method='post'> HTML form, but I can't "catch" the submit. Also I tried to catch it with jquery, $(document).ready(function() { $('.normal_button').click(function() { }); ); but I can't return false if a field wasn't completed correct.
I must use he's PHP function to insert the submit button, but how can I "catch" the fields, how can I validate them? Any suggestions? Thank you !