Is it compulsory to make templates of my form and then apply it in my page or can I simply make form action to go and validate data from another php file in wordpress directory?... although it does function completely without any errors... but a friend told me that wordpress requires templates for forms and any php???
<form action="mypageform.php" method="post" name="myForm" onSubmit="validateForm()">
Name
<input name="fullname" type="text" value="" />
Age
<input name="age" type="text" value="" />
Email-ID
<input name="email" type="text" value="" />
<input name="submit" type="submit" value="Submit" />
</form>
<script type="text/javascript">// <![CDATA[
function validateForm()
{
var x=document.forms["myForm"]["fullname"].value;
if (x==null || x=="")
{
alert("Name must be filled out");
return false;
}
var x=document.forms["myForm"]["age"].value;
if (x==null || x=="")
{
alert("Age must be filled out");
return false;
}
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
// ]]></script>
Aucun commentaire:
Enregistrer un commentaire