after input Auto Submit

when entered multiple inputs automatically submit

by sunil puvvada

HTML

<div class="container">  
	<input id="mmkverify-chk-otp1" name="somename" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type="number" maxlength="1" class="otp key" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
  <input id="mmkverify-chk-otp2" name="somename" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type="number" maxlength="1" class="otp key" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
  <input id="mmkverify-chk-otp3" name="somename" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type="number" maxlength="1" class="otp key" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
  <input id="mmkverify-chk-otp4" name="somename" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type="number" maxlength="1" class="otp key" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
  <input id="mmkverify-chk-otp5" name="somename" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type="number" maxlength="1" class="otp key" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
  <input id="mmkverify-chk-otp6" name="somename" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" type="number" maxlength="1" class="otp key" onkeypress='return event.charCode >= 48 && event.charCode <= 57' />
</div>

JavaScript

$(document).ready(function() {  
    function calc() { 
       var res =  $("#mmkverify-chk-otp1").val() + $("#mmkverify-chk-otp2").val() + $("#mmkverify-chk-otp3").val() + $("#mmkverify-chk-otp4").val() + $("#mmkverify-chk-otp5").val() + $("#mmkverify-chk-otp6").val();
        var tempValueCal = {
                        'lengthcl': res.length,
                        'valuecl': res
                    };
       
      
        return tempValueCal;
    }
    $(".key").keyup(function() {
       var valuelength = calc(); 
      if(valuelength.lengthcl >= 6){
      	alert("It will work");
      
      }
    });
});