I've created a form with html being echoed in PHP and am trying to call a Javascript function in the same form. I've copied and pasted the js part which I have put in my head tags at the top of the php file.
<script>
function validate(){
alert("You need to enter the date in format dd-mm-yyyy");
}
</script>
Further on I have this at the start of the form
echo "<form method=\"post\" action=\"index.php\" onsubmit=\"validate()\">
<br>
<span>Name: <input type=\"text\" name=\"name\" value=\"$name\"></span>"
Is it possible to call javascript from php in the same document? Cheers