VRFS-689 added validations for required fields
This commit is contained in:
parent
c3d49de7f1
commit
4fadedb04b
|
|
@ -33,41 +33,113 @@
|
|||
return genres;
|
||||
}
|
||||
|
||||
function validateForm() {
|
||||
function validateStep1() {
|
||||
var isValid = true;
|
||||
|
||||
// name
|
||||
var $name = $("#band-name");
|
||||
var $tdName = $("#tdBandName");
|
||||
var name = $.trim($name.val());
|
||||
if (name.length === 0) {
|
||||
$tdName.find('.error-text').remove();
|
||||
$tdName.addClass("error");
|
||||
$name.after("<ul class='error-text'><li>Name is required</li></ul>");
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
$tdName.removeClass("error");
|
||||
}
|
||||
|
||||
// country
|
||||
var $country = $("#band-country");
|
||||
var $tdCountry = $("#tdBandCountry");
|
||||
var country = $.trim($country.val());
|
||||
if (country.length === 0) {
|
||||
$tdCountry.find('.error-text').remove();
|
||||
$tdCountry.addClass("error");
|
||||
$country.after("<ul class='error-text'><li>Country is required</li></ul>");
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
$tdCountry.removeClass("error");
|
||||
}
|
||||
|
||||
// state
|
||||
|
||||
// region
|
||||
var $region = $("#band-region");
|
||||
var $tdRegion = $("#tdBandRegion");
|
||||
var region = $.trim($region.val());
|
||||
if (region.length === 0) {
|
||||
$tdRegion.find('.error-text').remove();
|
||||
$tdRegion.addClass("error");
|
||||
$region.after("<ul class='error-text'><li>Region is required</li></ul>");
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
$tdRegion.removeClass("error");
|
||||
}
|
||||
|
||||
// city
|
||||
var $city = $("#band-city");
|
||||
var $tdCity = $("#tdBandCity");
|
||||
var city = $.trim($city.val());
|
||||
if (city.length === 0) {
|
||||
$tdCity.find('.error-text').remove();
|
||||
$tdCity.addClass("error");
|
||||
$city.after("<ul class='error-text'><li>City is required</li></ul>");
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
$tdCity.removeClass("error");
|
||||
}
|
||||
|
||||
|
||||
// genres (no more than 3)
|
||||
var $genres = $(".band-setup-genres");
|
||||
var $tdGenres = $("#tdBandGenres");
|
||||
var selectedGenres = getSelectedGenres();
|
||||
logger.debug("selectedGenres=" + selectedGenres.length);
|
||||
if (selectedGenres.length === 0 || selectedGenres.length > 3) {
|
||||
$tdGenres.find('.error-text').remove();
|
||||
$tdGenres.addClass("error");
|
||||
$genres.after("<ul class='error-text'><li>Genre is required (3 maximum)</li></ul>");
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
$tdGenres.removeClass("error");
|
||||
}
|
||||
|
||||
// description
|
||||
|
||||
var $biography = $("#band-biography");
|
||||
var $tdBiography = $("#tdBandBiography");
|
||||
var biography = $.trim($biography.val());
|
||||
if (biography.length === 0) {
|
||||
$tdBiography.find('.error-text').remove();
|
||||
$tdBiography.addClass("error");
|
||||
$biography.after("<ul class='error-text'><li>Biography is required</li></ul>");
|
||||
isValid = false;
|
||||
}
|
||||
else {
|
||||
$tdBiography.removeClass("error");
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function createBand() {
|
||||
if (validateForm()) {
|
||||
var band = {};
|
||||
band.name = $("#band-name").val();
|
||||
band.website = $("#band-website").val();
|
||||
band.biography = $("#band-biography").val();
|
||||
band.city = $("#band-city").val();
|
||||
band.state = $("#band-state").val();
|
||||
band.country = $("#band-country").val();
|
||||
band.genres = getSelectedGenres();
|
||||
var band = {};
|
||||
band.name = $("#band-name").val();
|
||||
band.website = $("#band-website").val();
|
||||
band.biography = $("#band-biography").val();
|
||||
band.city = $("#band-city").val();
|
||||
band.state = $("#band-state").val();
|
||||
band.country = $("#band-country").val();
|
||||
band.genres = getSelectedGenres();
|
||||
|
||||
rest.createBand(band).done(function(response) {
|
||||
createBandInvitations(response.id, function() {
|
||||
context.location = "#/bandProfile/" + response.id;
|
||||
});
|
||||
rest.createBand(band).done(function(response) {
|
||||
createBandInvitations(response.id, function() {
|
||||
context.location = "#/bandProfile/" + response.id;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createBandInvitations(bandId, onComplete) {
|
||||
|
|
@ -245,12 +317,14 @@
|
|||
});
|
||||
|
||||
$('#btn-band-setup-cancel').click(function() {
|
||||
context.location = "#/";
|
||||
context.location = "#/home";
|
||||
});
|
||||
|
||||
$('#btn-band-setup-next').click(function() {
|
||||
$("#band-setup-step-2").show();
|
||||
$("#band-setup-step-1").hide();
|
||||
if (validateStep1()) {
|
||||
$("#band-setup-step-2").show();
|
||||
$("#band-setup-step-1").hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn-band-setup-back').click(function() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle" width="33%">Band Name:<br />
|
||||
<td id="tdBandName" valign="middle" width="33%">Band Name:<br />
|
||||
<input id="band-name" type="text" maxlength="1024" value="" class="w80"><br />
|
||||
</td>
|
||||
<td valign="middle" width="33%">Web Site:<br />
|
||||
|
|
@ -36,26 +36,26 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">Country:<br />
|
||||
<td id="tdBandCountry" valign="middle">Country:<br />
|
||||
<select id="band-country" class="w80">
|
||||
</select><br /><br />
|
||||
</td>
|
||||
<td valign="middle">State/Region:<br />
|
||||
<td id="tdBandRegion" valign="middle">State/Region:<br />
|
||||
<select id="band-region" class="w80">
|
||||
</select><br /><br />
|
||||
</td>
|
||||
<td valign="middle">City:<br />
|
||||
<td id="tdBandCity" valign="middle">City:<br />
|
||||
<select id="band-city" class="w80">
|
||||
</select><br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Genres:<br />
|
||||
<td id="tdBandGenres" valign="top">Genres:<br />
|
||||
<div class="band-setup-genres w90">
|
||||
<table id="band-genres" width="100%" cellpadding="10" cellspacing="6"></table>
|
||||
</div>
|
||||
</td>
|
||||
<td valign="top" colspan="2">Description / Bio:<br />
|
||||
<td id="tdBandBiography" valign="top" colspan="2">Description / Bio:<br />
|
||||
<textarea id="band-biography" class="band-setup-bio w90" maxlength="4000"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue