我有一个这样的表格:
<form action="" method="get" id="contact_form">
<input type="text" name="firstname" id="firstname" placeholder="Navn" value="">
<input type="text" name="telephone" id="telephone" placeholder="Telefonnummer" value="">
<input type="text" name="email" id="email" placeholder="Email" value="">
<textarea cols="1" rows="1" name="comment" id="comment" placeholder="Besked"></textarea>
<button>Submit</button>
<img src="" alt="" class="fa fa-spinner fa-pulse fa-3x fa-fw loader"/>
</form>
&#13;
使用javascript文件验证输入区域以及处理重定向到以下php文件:
<?php
$errorMSG = "";
// NAME
if (empty($_POST["firstname"])) {
$errorMSG = "Name is required ";
} else {
$name = $_POST["firstname"];
}
if (empty($_POST["telephone"])) {
$errorMSG .= "Telephone is required ";
} else {
$telephone = $_POST["telephone"];
}
// EMAIL
if (empty($_POST["email"])) {
$errorMSG .= "Email is required ";
} else {
$email = $_POST["email"];
}
// MESSAGE
if (empty($_POST["comment"])) {
$errorMSG .= "Message is required ";
} else {
$comment = $_POST["comment"];
}
$EmailTo = "EMAIL@EMAIL.com";
$Subject = "New Message Received";
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $telephone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From:".$email);
&#13;
由于无法在母版页文件中使用<form>
标记,如何添加表单?
尝试使用:https://sharepointformsubmit.codeplex.com/,遗憾的是没有做任何事情。是否可以创建Web部件页面并将表单粘贴到该页面然后在主页上链接到该页面?如果是这样,那么当涉及到javascript文件时,需要注意什么?