I need assistance with disabling a button until a minimum of 12 characters are entered into a text input field.
The platform I am working on utilizes Bootstrap and allows for custom JavaScript implementation.
Below is my code for a form builder that includes two functions - one to disable the submit button until the condition is met, and another to redirect to a different page after a set time:
<!--Formbuilder Form-->
<form action="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e293978386918d8496cc8b8c848da29b838a8d8af2fccd88eac0">••••••••</a>" id="loginForm" name="Contact Us Form" method="POST"
class="mbr-form form-with-styler">
<div class="row">
<div hidden="hidden" data-form-alert class="alert alert-success col-12">Thanks for filling out
the form! We will be in touch with you soon.</div>
<div hidden="hidden" data-form-alert-danger class="alert alert-danger col-12"> </div>
</div>
<div class="dragArea row">
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
<div class="form-row">
<div class="col">
<input type="text" id="fn" name="fn" placeholder="Enter Username" data-form-field="nameFirst"
required="required" class="form-control text-multiple" value="new">
</div>
<div class="col">
<input type="text" id="ln" name="ln" placeholder="Enter Password" data-form-field="nameLast"
required="required" class="form-control text-multiple" value="new">
</div>
</div>
</div>
<div class="col-md-6 input-group-btn btn" id="btnSubmit" mbr-buttons="true" mbr-theme-
style="display-4" data-toolbar="-mbrBtnMove,-mbrLink,-mbrBtnRemove,-mbrBtnAdd"><a
type="submit" class="btn btn-lg btn-primary" id="btnsubmit" data-app-placeholder="Type Text"
onclick="func1()" disabled="stateHandle()">Send message</a></div>
<script>
var btn = getElementById('btnSubmit');
function stateHandle(){
if(){ //Condition to check for 12 characters
btn.disabled = true;
}else if(){ //Another condition
btn.disabled = false;
}
}
function func1(){
window.setTimeout(function() {
window.location.href = 'index.html';
}, 3000);
}
</script>
</div>
</form><!--Formbuilder Form-->