I have the following button element in a form
<form action="#" method="post" id="commentform" >
<button name="submit" type="submit" id="submit" onmouseover="email();" >Submit Comment</button>
</form>
Then i have the following javascript code for email function
<script>
function email(){
$('document').ready(function (){
var name=$('#author').val();
var userEmail=$('#email').val();
var phone=$('#url').val();
var subject=$('#subject').val();
var comment=$('#comment').val();
var submit=$('#submit').val();
var form={
"name":name,
"userEmail":userEmail,
"phone":phone,
"subject":subject,
"comment":comment,
"submit":submit
};
console.log(form);
var array="Ta kena pedia einai: ";
for (var item in form) {
array=array+"\n"+"\n"+item+"\n";
if(item==null){
return item;
}
}
alert(array);
});
};
</script>
When i click the submit button the function not working and i have the following error in the console
Uncaught TypeError: email is not a function
at HTMLButtonElement.onmouseover
What is the problem and how i can fix it?