I'm just learning javascript and php. I created a contact form and I'd like the submit button to accomplish two things when I press it:
- submit the data to me (this part is working)
- read my onclick function (this part is not working)
<input id="submit" name="submit" type="submit" value="Submit" onclick="eatFood()">
<?php
if ($_POST['submit']) {
////?????
}
?>
I'm sending the data to my email, and so I get that. But the onclick
function doesn't seem to work. I tried reviewing add onclick function for submit button but it didn't help.
eatFood
function in that code. – Maitunddocument.forms['formID'].reportValidity()
returns true if all the form elements validity is true. – Sihun