updated
This commit is contained in:
@@ -115,12 +115,15 @@
|
||||
|
||||
$("#frm-register").validate({
|
||||
rules: {
|
||||
name: {
|
||||
firstname: {
|
||||
required: true
|
||||
},
|
||||
username: {
|
||||
lastname: {
|
||||
required: true
|
||||
},
|
||||
// username: {
|
||||
// required: true
|
||||
// },
|
||||
email: {
|
||||
required: true,
|
||||
email: true
|
||||
@@ -128,6 +131,24 @@
|
||||
password: {
|
||||
required: true
|
||||
//minlength: 6 // <-- removed underscore
|
||||
},
|
||||
mobilenumber: {
|
||||
required: true
|
||||
},
|
||||
address: {
|
||||
required: true
|
||||
},
|
||||
state: {
|
||||
required: true
|
||||
},
|
||||
city: {
|
||||
required: true
|
||||
},
|
||||
zipcode: {
|
||||
required: true
|
||||
},
|
||||
countryCode: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {},
|
||||
@@ -182,6 +203,148 @@
|
||||
|
||||
}); // end document ready
|
||||
|
||||
|
||||
function getSelectedCountry() {
|
||||
var selectedState = $('#select_country').data('selected');
|
||||
if (selectedState) {
|
||||
// console.log(selectedState)
|
||||
$("#select_country").val(selectedState).change();
|
||||
// selectCountry()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function selectCountry(item) {
|
||||
|
||||
const country = item.options[item.selectedIndex].text;
|
||||
const countryCode = item.options[item.selectedIndex].value
|
||||
console.log(countryCode)
|
||||
|
||||
if (countryCode === "US") {
|
||||
fetchUSA()
|
||||
}
|
||||
|
||||
if (countryCode === "CA") {
|
||||
fetchCanada()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fetchCanada() {
|
||||
$.getJSON("{{ asset('/public/api/canada.json') }}", function(items) {
|
||||
var states = [];
|
||||
|
||||
Object.keys(items).forEach(function(state) {
|
||||
states.push(state)
|
||||
});
|
||||
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
|
||||
$('.dynamic-state').remove();
|
||||
$('.dynamic-city').remove();
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if (selectedState == key) {
|
||||
$('#lst-states').append('<option value="' + key + '" selected class="dynamic-state">' + key + '</option>');
|
||||
|
||||
var cities = [];
|
||||
cities = items[selectedState];
|
||||
var uniqueCities = Array.from(new Set(cities));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if (selectedCity == key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city" selected>' + key + '</option>');
|
||||
} else {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#lst-states').append('<option value="' + key + '" class="dynamic-state">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function() {
|
||||
var cities = [];
|
||||
var selectedState = $(this).val()
|
||||
cities = items[selectedState];
|
||||
var uniqueCities = Array.from(new Set(cities));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchUSA() {
|
||||
$.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) {
|
||||
var states = [];
|
||||
|
||||
for (i = 0; i < data.length; i++) {
|
||||
states.push(data[i]['state']);
|
||||
}
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
$('.dynamic-state').remove();
|
||||
$('.dynamic-city').remove();
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if (selectedState == key) {
|
||||
$('#lst-states').append('<option value="' + key + '" selected class="dynamic-state">' + key + '</option>');
|
||||
//
|
||||
var cities = [];
|
||||
for (i = 0; i < data.length; i++) {
|
||||
console.log(data[i])
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, key);
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if (selectedCity == key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city" selected>' + key + '</option>');
|
||||
} else {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#lst-states').append('<option value="' + key + '" class="dynamic-state">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function() {
|
||||
var cities = [];
|
||||
for (i = 0; i < data.length; i++) {
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, $(this).val());
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function getCities(arr, q) {
|
||||
var sd = [];
|
||||
arr.find(function(element) {
|
||||
if (element['state'] == q) {
|
||||
sd.push(element['city']);
|
||||
}
|
||||
});
|
||||
return sd;
|
||||
}
|
||||
|
||||
function submitLoginForm() {
|
||||
// method="POST" action="{{ url('/auth/login') }}"
|
||||
var data = $("#frm-login").serialize();
|
||||
@@ -218,7 +381,13 @@
|
||||
} /* login submit */
|
||||
|
||||
function submitRegisterForm() {
|
||||
var data = $("#frm-register").serialize();
|
||||
|
||||
var data = $("#frm-register").serializeArray();
|
||||
data.push({
|
||||
name: "country",
|
||||
value: $("#select_country option:selected").text()
|
||||
});
|
||||
// var data = $("#frm-register").serialize();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user