onclick event
<button type="submit" value="submit" class="login100-form-btn" onClick="this.validate-input">
Create Account
</button>
and
<button type="submit" value="submit" class="login100-form-btn" onClick="this.disabled=true">
Create Account
</button>
works separately but
<button type="submit" value="submit" class="login100-form-btn" onClick="this.validate-input; this.disabled=true">
Create Account
</button>
does not work together. Please suggest me how can I
EDIT
I have downloaded this code from colorlib.com. When I click the submit button two times together, it gives an error. So I want to disable the submit button once clicked.
Please checkout my jQuery
var input = $('.validate-input .input100');
$('.validate-form').on('submit', function() {
var check = true;
for (var i = 0; i < input.length; i++) {
if (validate(input[i]) == false) {
showValidate(input[i]);
check = false;
}
}
return check;
});
$('.validate-form .input100').each(function() {
$(this).focus(function() {
hideValidate(this);
});
});
function validate(input) {
if ($(input).attr('type') == 'email' || $(input).attr('name') == 'email') {
if ($(input).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) {
return false;
}
} else {
if ($(input).val().trim() == '') {
return false;
}
}
}
function showValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).addClass('alert-validate');
}
function hideValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).removeClass('alert-validate');
}
You can add disabling the submit button to the validation function.
$('.validate-form').on('submit', function() {
var check = true;
for (var i = 0; i < input.length; i++) {
if (validate(input[i]) == false) {
showValidate(input[i]);
check = false;
}
}
if (check) {
$(this).find(":submit").prop("disabled", true);
}
return check;
});