JSFiddle - React, Tailwind, and code Playground
by Hifni Nazeer
HTML
<input type="text" id="txtInput" placeholder="otp"/>
<div>
hello
</div>
<button type="button" id="btnValidate">
Validate
</button>
<button type="submit">
Submit
</button>
JavaScript
$(document).ready(function(){
alert('Welcome');
$('button[type="submit"]').prop( "disabled", true );
$('#txtInput').keyup(function(){
var str = $(this).val();
console.log(str);
$('div').html('<p>You are typing....' + str +'</p>');
var reg = new RegExp("[0-9]{6}");
if (reg.test(str)) {
$('button[type="submit"]').prop( "disabled", false );
}
else{
$('button[type="submit"]').prop( "disabled", true );
}
});
});