Super noob to html/php, hopefully you go easy on me I think I learned just enough to be dangerous lol
Trying to cobble together a basic contact form on a small website project, found a html5 template and some basic code to validate the form variables, and use PHPMailer to send. I am trying to call what seems like a function in jquery, from the form elements to verify the variable entries. Using this as my project to wrap my head around working with scripting in html so far.
Here are the html form elements from index.php:
<form method="post" action="#"> <div class="fields"> <div class="field"> <label for="name">Name</label> <input type="text" name="name" id="name" /> </div> <div class="field"> <label for="email">Email</label> <div.............. </div> <ul class="actions"> <li><input type="submit" onclick="sendEmail()" value="Send Message"/></li> </ul> </form>
It seems I have two action items,
<form method="post" action="#">
wants a script name,
and the other line:
<li><input type="submit" onclick="sendEmail()" value="Send Message"/></li>
Does nothing when clicked. The code works as I have it on my sandbox server, but it does not run the entry validation checks on the fields. and doesn’t handle the response, just reloads the index page.
Can anyone point me to examples when calling jquery functions from php/html forms? I am still learning syntax by example if it doesn’t show lol Any help would be greatly appreciated. I am working on much simpler example code, and everything works - or so I think I have my head wrapped around it, then I get lost as soon as I want to add a bit more logic.