fix(master-land): create validate input no Hp and date
This commit is contained in:
parent
f8732a5bb6
commit
09989ec7ff
|
@ -1,20 +1,5 @@
|
||||||
var map;
|
var map;
|
||||||
var currentMarker = null;
|
var currentMarker = null;
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
// Initialize the first map
|
|
||||||
map = L.map("map", {
|
|
||||||
attributionControl: false,
|
|
||||||
}).setView([-8.157416852745705, 113.72281580436439], 16);
|
|
||||||
|
|
||||||
// Add tile layers to both maps
|
|
||||||
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
|
||||||
maxZoom: 19,
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
$("#showModal").on("shown.bs.modal", function () {
|
|
||||||
map.invalidateSize();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
var form = document.getElementById("add-form");
|
var form = document.getElementById("add-form");
|
||||||
var provinceField = form.querySelector("#province-field");
|
var provinceField = form.querySelector("#province-field");
|
||||||
|
@ -36,6 +21,34 @@ var mapContainer = form.querySelector("#map-container");
|
||||||
|
|
||||||
var loading = form.querySelector("#loading");
|
var loading = form.querySelector("#loading");
|
||||||
|
|
||||||
|
var btnContainer = form.querySelector("#btn-container");
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
// Initialize the first map
|
||||||
|
map = L.map("map", {
|
||||||
|
attributionControl: false,
|
||||||
|
}).setView([-8.157416852745705, 113.72281580436439], 16);
|
||||||
|
|
||||||
|
// Add tile layers to both maps
|
||||||
|
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||||
|
maxZoom: 19,
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
$("#showModal").on("shown.bs.modal", function () {
|
||||||
|
map.invalidateSize();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function validatePhoneNumber(input) {
|
||||||
|
input.value = input.value.replace(/\D/g, "");
|
||||||
|
|
||||||
|
if (input.value.length < 10 || input.value.length > 13) {
|
||||||
|
input.setCustomValidity("Nomor telepon tidak valid");
|
||||||
|
} else {
|
||||||
|
input.setCustomValidity("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getRegencies(provinceId) {
|
function getRegencies(provinceId) {
|
||||||
regencyContainer.style.display = "none";
|
regencyContainer.style.display = "none";
|
||||||
districtContainer.style.display = "none";
|
districtContainer.style.display = "none";
|
||||||
|
@ -90,8 +103,6 @@ function getRegencies(provinceId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showmap(districtId) {
|
function showmap(districtId) {
|
||||||
mapContainer.style.display = "block";
|
|
||||||
map.invalidateSize();
|
|
||||||
if (!navigator.geolocation) {
|
if (!navigator.geolocation) {
|
||||||
alert("Geolocation tidak didukung oleh browser ini.");
|
alert("Geolocation tidak didukung oleh browser ini.");
|
||||||
return;
|
return;
|
||||||
|
@ -99,6 +110,9 @@ function showmap(districtId) {
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition(
|
navigator.geolocation.getCurrentPosition(
|
||||||
function (position) {
|
function (position) {
|
||||||
|
mapContainer.style.display = "block";
|
||||||
|
map.invalidateSize();
|
||||||
|
btnContainer.style.display = "block";
|
||||||
var lat = position.coords.latitude;
|
var lat = position.coords.latitude;
|
||||||
var lng = position.coords.longitude;
|
var lng = position.coords.longitude;
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,8 @@ class="fw-medium link-primary">#VZ2101</a></td>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="nohp-field" class="form-label">Nomor HP</label>
|
<label for="nohp-field" class="form-label">Nomor HP</label>
|
||||||
<input type="text" id="nohp-field" class="form-control" name="nohp"
|
<input type="text" id="nohp-field" class="form-control" name="nohp"
|
||||||
value="{{ old('nohp') }}" placeholder="Masukan Nomor HP" required />
|
value="{{ old('nohp') }}" placeholder="Masukan Nomor HP" required
|
||||||
|
oninput="validatePhoneNumber(this)" />
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
Masukan Nomor HP
|
Masukan Nomor HP
|
||||||
</div>
|
</div>
|
||||||
|
@ -184,7 +185,7 @@ class="fw-medium link-primary">#VZ2101</a></td>
|
||||||
<label for="rentalstart-field" class="form-label">Mulai Dari</label>
|
<label for="rentalstart-field" class="form-label">Mulai Dari</label>
|
||||||
<input type="date" id="rentalstart-field" class="form-control"
|
<input type="date" id="rentalstart-field" class="form-control"
|
||||||
name="rental_start" value="{{ old('rental_start') }}"
|
name="rental_start" value="{{ old('rental_start') }}"
|
||||||
placeholder="Masukan Tanggal Mulai" required />
|
min="{{ date('Y-m-d') }}" placeholder="Masukan Tanggal Mulai" required />
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
Masukan Tanggal Mulai
|
Masukan Tanggal Mulai
|
||||||
</div>
|
</div>
|
||||||
|
@ -195,7 +196,8 @@ class="fw-medium link-primary">#VZ2101</a></td>
|
||||||
<label for="rentaluntil-field" class="form-label">Sampai</label>
|
<label for="rentaluntil-field" class="form-label">Sampai</label>
|
||||||
<input type="date" id="rentaluntil-field" class="form-control"
|
<input type="date" id="rentaluntil-field" class="form-control"
|
||||||
name="rental_until" value="{{ old('rental_start') }}"
|
name="rental_until" value="{{ old('rental_start') }}"
|
||||||
placeholder="Masukan Tanggal Sampai" required />
|
min="{{ date('Y-m-d') }}" placeholder="Masukan Tanggal Sampai"
|
||||||
|
required />
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
Masukan Tanggal Sampai
|
Masukan Tanggal Sampai
|
||||||
</div>
|
</div>
|
||||||
|
@ -261,7 +263,7 @@ class="fw-medium link-primary">#VZ2101</a></td>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<div class="hstack gap-2 justify-content-end">
|
<div class="hstack gap-2 justify-content-end" id="btn-container" style="display: none">
|
||||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Tutup</button>
|
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Tutup</button>
|
||||||
<button type="submit" class="btn btn-success" id="add-btn">Simpan</button>
|
<button type="submit" class="btn btn-success" id="add-btn">Simpan</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue