Update Banyak
This commit is contained in:
+39
-2
@@ -67,8 +67,13 @@
|
||||
</div>
|
||||
<div class="form-group m-1">
|
||||
<label>Email</label>
|
||||
<input type="email" class="form-control" name="email">
|
||||
<input type="email" class="form-control" required="required" name="email" id="emailInput">
|
||||
<small id="emailError"></small>
|
||||
</div>
|
||||
<!--<div class="form-group m-1">-->
|
||||
<!-- <label>Email</label>-->
|
||||
<!-- <input type="email" class="form-control" name="email">-->
|
||||
<!--</div>-->
|
||||
<div class="form-group m-1">
|
||||
<label>Nomor WhatsApp</label>
|
||||
<input type="text" class="form-control" name="nowa">
|
||||
@@ -250,4 +255,36 @@ if (isset($_POST['tambah'])) {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const emailInput = document.getElementById("emailInput");
|
||||
const emailError = document.getElementById("emailError");
|
||||
const gmailRegex = /^[a-z0-9._%+-]+@gmail\.com$/;
|
||||
|
||||
// Saat ngetik
|
||||
emailInput.addEventListener("input", function() {
|
||||
this.value = this.value.toLowerCase();
|
||||
|
||||
if (gmailRegex.test(this.value)) {
|
||||
emailError.textContent = "✅ Email valid";
|
||||
emailError.style.color = "green";
|
||||
} else {
|
||||
emailError.textContent = "❌ Email tidak valid (harus @gmail.com & huruf kecil)";
|
||||
emailError.style.color = "red";
|
||||
}
|
||||
});
|
||||
|
||||
// Saat submit
|
||||
emailInput.form.addEventListener("submit", function(e) {
|
||||
if (!gmailRegex.test(emailInput.value)) {
|
||||
e.preventDefault(); // stop submit
|
||||
emailError.textContent = "❌ Email tidak valid (harus @gmail.com & huruf kecil)";
|
||||
emailError.style.color = "red";
|
||||
emailInput.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="dist/js/mapsFormCustom.js"></script>
|
||||
Reference in New Issue
Block a user