FIX_Customer validation redo

This commit is contained in:
VE10-Sanjeev 2024-11-21 06:56:48 +00:00
parent 0bca631a03
commit 1fb5e647fe

View File

@ -40,8 +40,8 @@
<div class="invalid-feedback"> Please provide. </div> <div class="invalid-feedback"> Please provide. </div>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cmail" class="col-form-label">Email</label> <label for="cmail" class="col-form-label">Email<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cmail')" /> <input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cmail')" required />
<span id="emailValidationMessage"></span> <span id="emailValidationMessage"></span>
</div> </div>
</div> </div>
@ -556,16 +556,18 @@
</script> </script>
<script> <script>
document.getElementById('myForm').addEventListener('submit', function(event) { document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target; var form = event.target;
if (form.checkValidity() === false) {
// Check if form is valid
if (!form.checkValidity()) {
event.preventDefault(); // Prevent form submission
form.reportValidity(); // Display validation error messages
$('#submitBtn').prop('disabled', false); // Re-enable the button
} else {
$('#submitBtn').prop('disabled', true); // Disable the button to prevent duplicate submissions
}
});
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
});
</script> </script>
<script> <script>
function validateEmail(email) { function validateEmail(email) {