我的聯繫表單需要一些幫助。我正在Dreamweaver上構建我的網站,而且我還沒有服務器,我只需要你告訴我在我的代碼中還缺少了什麼是我的聯繫表單工作。 2-我還需要「發送的消息」出現在消息的下面,因爲我的網站是一個視差的單頁面。我不想讓人們離開我的page.I不知道往哪裏放我的E-mail地址:(聯繫表單幫助不大?
(function($){
\t $(document).ready(function() {
\t \t $('#submit-form').click(function(e){
\t \t
\t \t \t e.preventDefault();
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var Nome = $('#form_name').val(),
\t \t \t \t Email = $('#form_email').val(),
\t \t \t \t Assunto = $('#form_subject').val(),
\t \t \t \t Mensagem = $('#form_message').val(),
\t \t \t \t data_html,
\t \t \t \t success = $('#success');
\t \t \t \t
\t \t if(name == "")
$('#form_name').val('Please enter your name.');
\t \t \t \t
\t \t \t if(subject == "")
$('#form_subject').val('Please enter your name.');
if(email == ""){
$('#form_email').val('Digite um e-mail válido.');
}else if(reg.test(email) == false){
$('#form_email').val('E-mail inválido.');
}
\t \t \t
if(message == "")
$('#form_message').val('Digite sua mensagem.');
if(message != "" && name != "" && reg.test(email) != false) {
\t data_html = "name=" + name + "&email="+ email + "&message=" + message + "&subject="+ subject;
//alert(data_html);
$.ajax({
type: 'POST',
url: 'contact_form.php',
data: data_html,
success: function(msg){
\t \t \t \t \t \t
\t \t \t \t \t \t if (msg == 'sent'){
\t success.html('<div class="alert alert-success">Mensagem enviada!</div>') ;
$('#form_name').val('');
\t \t \t \t \t \t \t $('#form_email').val('');
\t \t \t \t \t \t \t $('#form_message').val('');
}else{
success.html('<div class="alert alert-error">Message <strong>not</strong> sent! Please Try Again!</div>') ;
}
}
});
}
return false;
});
\t });
})(jQuery);
textarea {
\t height:167px;
\t padding:20px;
\t margin-bottom:20px;
\t overflow:auto;
}
\t
.formSecWrap {
\t float: left;
\t margin-right: 20px;
}
.formSecWrap2 {
\t margin-right: 0px;
}
input[type="text"], input[type="password"], input[type="email"], textarea, select {
background: #222222;
border: none;
border-radius: 3px;
color: #fff;
display: block;
margin: 0 0 10px 0;
outline: medium none;
padding: 6px 4px;
width: 370px;
\t font-family:'Oswald', sans-serif;
\t font-size: 16px;
\t font-weight: 400;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, textarea:focus {
box-shadow: 0 0 7px #fff;
}
.formWrap label{
\t margin: 0 0 2px 0;
}
.formWrap input[type="submit"]{
\t margin: 10px 0 20px 0;
\t float: right;
}
a.button,
button,
input[type="submit"],
input[type="reset"],
input[type="button"] {
\t background: #7b133c;
\t border: none;
\t padding: 4px 12px;
\t border-radius: 3px;
\t color: #fff;
\t display: inline-block;
\t font-size: 13px;
\t text-decoration: none;
\t cursor: pointer;
\t margin: 0 5px 10px 0;
\t line-height: 21px;
}
a.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
input[type="button"]:hover {
\t color: #222;
\t background: #ddd;
}
<div id="contact_form">
<div class="two-thirds column marginTop formWrap">
<form action="#" method="post" class="contactForm">
<div class="formSecWrap">
<label for="form_name">Nome</label>
<input type="text" id="form_name" name="form_name" value="" />
<label for="form_email">Email</label>
<input type="text" name="form_email" id="form_email" value="" />
<label for="form_subject">Assunto</label>
<input type="text" name="form_subject" id="form_subject" value="" />
</div>
<div class="formSecWrap formSecWrap2">
<label for="form_message">Mensagem</label>
<textarea class="textarea" name="form_message" id="form_message"></textarea>
<input class="button" id="submit-form" type="submit" name="submit" value="Enviar" />
</div>
<div id="sucess"></div>
</form>
</div>
</div>
\t </div>
</div>
這裏有一個url文件'contact_form.php'。那裏有什麼?應該有電子郵件地址。 – 2015-02-11 22:56:25
@Claudiu,是的,我使用了.php ...但是恐怕它會帶我到另一頁呢?沒有? – 2015-02-11 22:59:20