Привет
написал форму рег.
только учу javascript , прошу сильно не критиковать .
вот форма + js
<script>
$(document).ready(function() {
$("#ajaxform").submit(function(){
var form = $(this);
var error = false;
form.find('input, textarea').each( function(){
if ($(this).val() == '') { // eсли нaхoдим пустoe
alert('Зaпoлнитe пoлe "'+$(this).attr('placeholder')+'"!');
error = true; // oшибкa
}
});
if (!error) { // eсли oшибки нeт
var data = form.serialize();
$.ajax({
type: 'POST',
url: 'gogogo.php',
dataType: 'json',
data: data,
beforeSend: function(data) {
form.find('input[type="submit"]').attr('disabled', 'disabled');
},
success: function(data){
if (data['error']) {
alert(data['error']);
} else {
alert('Письмo oтврaвлeнo! Чeкaйтe пoчту! =)');
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
},
complete: function(data) {
form.find('input[type="submit"]').prop('disabled', false);
}
});
}
return false;
});
});
</script>
html
<div class="container">
<form class="form-horizontal" role="form" method="post" action="finish-reg.php" id="ajaxform">
<h2>Registration Form</h2>
<div class="form-group">
<label for="firstName" class="col-sm-3 control-label">Numele Complet</label>
<div class="col-sm-9">
<input type="text" id="firstName" placeholder="ex: James Bond" class="form-control" autofocus>
<span class="help-block">Numele, Prenumele</span>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email adresa</label>
<div class="col-sm-9">
<input type="email" id="email" placeholder="email" class="form-control">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Parola</label>
<div class="col-sm-9">
<input type="password" id="password" placeholder="parola" class="form-control">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Parola repetata</label>
<div class="col-sm-9">
<input type="password" id="RePassword" placeholder="control parola" class="form-control">
</div>
</div>
<div class="form-group">
<label for="birthDate" class="col-sm-3 control-label">Birth Date</label>
<div class="col-sm-9">
<input type="date" id="birthDate" class="form-control">
</div>
Zi,luna,an : ex. 3.02.1999
</div>
<div class="form-group">
<label for="country" class="col-sm-3 control-label">Tara</label>
<div class="col-sm-9">
<select id="dhtmlgoodies_country" name="dhtmlgoodies_country" onchange="getCityList(this)">
<option value="">Country</option>
<option value="md">Moldova</option>
<option value="ro">Romania</option>
<option value="ru">Russia</option>
</select>
<tr>
<td>Orasul: </td>
<td><select id="dhtmlgoodies_city" name="dhtmlgoodies_city">
</select>
</td>
</tr>
</div>
</div> <!-- /.form-group -->
<div class="form-group">
<label class="control-label col-sm-3">Genul</label>
<div class="col-sm-6">
<div class="row">
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" id="femaleRadio" value="Female">Feminin
</label>
</div>
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" id="maleRadio" value="Male">Masculin
</label>
</div>
</div>
</div>
</div> <!-- /.form-group -->
<div class="form-group">
<div class="col-sm-9 col-sm-offset-3">
<button type="submit" class="btn btn-primary btn-block">Register</button>
</div>
</div>
</form> <!-- /form -->
</div> <!-- ./container -->
как сделать проверку на то если человек выбрал страну + город и если выбрал дату рождения ?