JSFiddle - React, Tailwind, and code Playground
by pratik24
HTML
<input id="lpnz_dup" class="diagTextArea" style=" width:216px;" placeholder="10"/>
<input id="lpnz1_dup" class="diagTextArea" style=" width:30px;" placeholder="10"/>
<input id="lpnz2_dup" class="diagTextArea" style=" width:30px;" placeholder="10"/>
<input id="lpnz3_dup" class="diagTextArea" style=" width:30px;" placeholder="10"/>
<input id="lpnz4_dup" class="diagTextArea" style=" width:30px;" placeholder="10"/>
<br>
<input id="dup" class="diagTextArea" style=" width:100px;" placeholder=""/>
<br>
<input id="dup1" class="diagTextArea" style=" width:100px;" placeholder=""/>
JavaScript
$('document').ready(function(){
var getKey="";
var getVal="";
var someval="";
var dotcount=0;
var keypressCnt=0;
var addChar="";
$("#lpnz_dup").keyup(function(e){
keypressCnt++;
if(e.keyCode == 190)
{
alert("happy");
dotcount++;
}
if( dotcount == 0){
$("#lpnz1_dup").val($(this).val());
}
else if(dotcount == 1){
var wholeval = $(this).val();
console.log("wholeval:"+wholeval);
someval = wholeval.split(".",1);
$("#dup").val(someval);
var sliceCnt = $("#dup").val().length; console.log("dup_length:"+$("#dup").val().length);
someval.slice(keypressCnt)
addChar += String.fromCharCode(e.which)
$("#lpnz2_dup").val($(this).val().slice(sliceCnt+1));
}
else if(dotcount == 2) {
var wholeval = $(this).val();
var secondval = wholeval.split(".",2);
$("#dup1").val(secondval);
var sliceCnt = $("#dup1").val().length;
$("#lpnz3_dup").val($(this).val().slice(sliceCnt+1));
}
});
});