mam o to taki kodzik do formularza który nie działa. Kod krtóry jest w warunku po spełnieniu działa np. w procedurze "else"
Kod
$(document).ready(function() {
$('input#send').click(function() {
var car = $('#car').val();
var phone = $('#phone').val();
var mail = $('#mail').val();
var text = $('#text').val();
if (car != "" && phone != "" && mail != "" && text != "") {
$('#form-mail').fadeOut();
setTimeout(function() {
$('div#sendOk').fadeIn();
}, 100);
setTimeout(function() {
$('div#sendOk').fadeOut();
}, 3000);
setTimeout(function() {
$('#form-mail').fadeIn();
}, 3000);
}else{
alert('Proszę uzupełnić wszystkie dane');
}
});
});
$('input#send').click(function() {
var car = $('#car').val();
var phone = $('#phone').val();
var mail = $('#mail').val();
var text = $('#text').val();
if (car != "" && phone != "" && mail != "" && text != "") {
$('#form-mail').fadeOut();
setTimeout(function() {
$('div#sendOk').fadeIn();
}, 100);
setTimeout(function() {
$('div#sendOk').fadeOut();
}, 3000);
setTimeout(function() {
$('#form-mail').fadeIn();
}, 3000);
}else{
alert('Proszę uzupełnić wszystkie dane');
}
});
});
HTML
Kod
<form id="form-mail" action="#" method="post">
<input id="car" class="input" type="text" name="name" placeholder="Imię i nazwisko" required/>
<input id="phone" class="input" type="tel" name="phone" placeholder="Telefon" required/>
<input id="mail" class="input" type="email" name="mail" placeholder="Email" required/>
<textarea id="text" placeholder="Treść" required></textarea>
<input class="sub" id="reset" type="reset" value="" /><input class="sub" id="send" type="submit" value="" />
</form>
<div id="sendOk">
<img src="img/ok-ico.png" alt="Ok" /> <p>Wiadomość została poprawnie wysłana</p>
</div>
<input id="car" class="input" type="text" name="name" placeholder="Imię i nazwisko" required/>
<input id="phone" class="input" type="tel" name="phone" placeholder="Telefon" required/>
<input id="mail" class="input" type="email" name="mail" placeholder="Email" required/>
<textarea id="text" placeholder="Treść" required></textarea>
<input class="sub" id="reset" type="reset" value="" /><input class="sub" id="send" type="submit" value="" />
</form>
<div id="sendOk">
<img src="img/ok-ico.png" alt="Ok" /> <p>Wiadomość została poprawnie wysłana</p>
</div>
jak podaje adres email to tqa zmienna się krzaczy
Kod
var mail = $('#mail').val();