[RESOLVED] Form validating issues; form action to php file negates validation, why?
I’ve been trying to mesh tutorials and this is what I’ve come up with. However, my “Your message has been sent” alert which I was trying to apply at the end (if everything was verified) never comes through and I’m absolutely stumped. Any pointers would be greatly appreciated.
Now my other issue is that when I attach the php file (below) to the form action (ie. action=”myfile.php”) – the form no longer even bothers to remotely try to validate. It just sends the contents straight through and I get my “Your message has been sent message” and this also confuses me. I thought checkform() needed to come back as true for the submit button to move the user forward.
if (document.contactAPC.name.value == '')
alert('Please enter a name.');
else if(document.contactAPC.email.value == '')
alert('Please enter an email address.');
else if(document.contactAPC.message.value == '')
alert('Please write a message.');
else if(document.contactAPC.email.value != '')
emailpattern = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
alert("Please enter a valid email address");
//Why can't I get this message to show?
alert("Your message has been sent.");
<form name="contactAPC" method="post" action="" onSubmit="return checkform()">
Name <input type="text" size="26" id="name" name="name" class="txtfield_details">
<br />Email <input type="text" size="26" id="email" name="email" class="txtfield_details">
<br /><textarea cols="24" rows="4" class="txtfield_details" name="message" id="message"></textarea>
<br /><input type="submit" value="Submit" name="submit" class="btns" />
<input type="reset" value="Clear" name="clear" class="btns" />
$email = $_REQUEST['email'] ;
mail( "email@example.com "From my Website",
$message, "From: $email" );