表单验证专家,我可以使用您的帮助。我正在尝试将图稿提交表单提交输入字段到数据库以及弹出"可打印"提交表格在新窗口中提交。 (前面提到过的" popup"窗口就是这个问题本身就是独一无二的。请参阅标有" Javascript" 的部分。无论出于何种原因,表单都会验证,但是,我没有在PHP存放邮件的电子邮件地址收到回复。提前致谢! -qs
HTML:
<form action="mailer.php" method="post" id="signup" name="signup" onsubmit="return checkForm();">
<table width="686" cellspacing="2px" cellpadding="2px">
<tr>
<td width="190" class="gradtable"><p>Date submitted: <span style="color:red;"><small>*</small></span></p></td>
<td width="470" class="gradtable"><span class="gradtablefootnotes"><span class="gradtable"><span class="gradtable"></span></span></span>
<input name="first" type="text" size="50" id="first" class="required" /></td>
</tr>
<tr>
<td class="gradtable"><p>Name: <span style="color:red;"><small>*</small></span></p></td>
<td class="gradtable"><input name="last" type="text" size="50" id="last" class="required" /></td>
</tr>
<tr>
<td class="gradtable"><p>Email: <span style="color:red;"><small>*</small></span></p></td>
<td class="gradtable"><input name="email" type="text" size="50" id="email" class="required" /></td>
</tr>
<tr>
<td class="gradtable"><p>Telephone: </p></td>
<td class="gradtable"><input name="phone" type="text" size="50" id="phone" /></td>
</tr>
<tr>
<td class="gradtable"><p>Category: <span style="color:red;"><small>*</small></span></p></td>
<td class="gradtable">
<input name="category" type="text" size="50" id="category" class="required" />
</td>
</tr>
<tr>
<td class="gradtable">Title of piece: <span style="color:red;"><small>*</small></span></td>
<td class="gradtable">
<input name="title" type="text" size="50" id="title" class="required" />
</td>
</tr>
<tr>
<td class="gradtable">Main medium used:</td>
<td class="gradtablefootnotes">
<input name="medium" type="text" size="50" />
</td>
</tr>
</table>
<input type="submit"value="SUBMIT"/>
</form>
使用Javascript:
$(document).ready(function() {
$('#signup').validate({
rules: {
first: {
required: true
},
last: {
required: true
},
email: {
required: true,
email: true,
},
category: {
required: true
},
title: {
required: true
},
}, //end rules
messages: {
first: {
required: "Please enter the submission date."
},
last: {
required: "Please enter your first and last name.",
},
email: {
required: "Please supply an e-mail address.",
email: "This is not a valid email address."
},
category: {
required: "Please supply the entry category.",
},
title: {
required: "Please provide the title of the piece."
},
}
}); // end validate
}); // end ready
$(document).ready(function(){
$('#signup').submit(function(){
if ($('#first').val() == ''){
return false;
} else if ($('#last').val() == ''){
return false;
} else if ($('#email').val() == ''){
return false;
} else if ($('#category').val() == ''){
return false;
} else if ($('#title').val() == ''){
return false;
} openForm();
});
});
function openForm(url){
pop = window.open("Art Submission Form.pdf","pop","scrollbars=yes");
testPop = (pop == null || typeof(pop) == "undefined") ? true:
false;
return testpop;
}
</script>
PHP:
<?php
$date = $_POST['date'];
$name = $_POST['name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$category = $_POST['category'];
$title = $_POST['title'];
$medium = $_POST['medium'];
$formcontent=" Date submitted: $date
\n Name: $name
\n Email: $email
\n Telephone: $telephone
\n category: $category
\n title: $title
\n medium: $medium ";
$recipient = "artbin@somedomain.com";
$subject = "2014 Student Art Show Submission";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank you for registering for the Student Show. " . " " . "<a
href='index.html' style='text-decoration:none;color:#fffff;'> </a>";
?>