you can add this code for number to word.if your field are coming dynamic.Just apply the class ".numtowordcls" on your input type
function getNumberToWord(thisObj){
var dataType=$(thisObj).attr("dir");
if(dataType!=null && dataType!="" ){
var value=$(thisObj).val();
if(dataType==='decimal' || dataType==='currency' || dataType==='number' || dataType==='emd' ){
if(value!=undefined && value.trim()!="" ){
if(isNaN(value)){
alert("Kindly Enter Valid Value For Filed Type '"+dataType+"'");
$(thisObj).val("");
$(thisObj).focus();
}else{
if(value!=undefined && value.trim()!=""){
if(!$.isNumeric(value)){
alert("Please Eneter Numeric value !!!");
$(this).val('');
return false;
}
var firstPart=value.toString().split(".")[0];
if(firstPart.length>14){
alert("Please Enter value upto 14 Digit !!!");
$(thisObj).val(value.substr(0,14));
$(thisObj).focus();
return false;
}
var secondPart=value.toString().split(".")[1];
if(secondPart!=undefined && secondPart!="" && secondPart.length>2){
alert("Decimal allowed upto 2 places !!!");
$(thisObj).val(value.substr(0,14));
$(thisObj).focus();
return false;
}
}
}
}
}
}
$(".numtowordcls").each(function(){
var id=$(this).attr("id");
var dirObj=$(this).attr("dir");
var dataArray=id.split("_");
var finalId=dataArray[0]+"_"+dataArray[1]+"_"+dirObj;
var fieldvalue=$("#"+finalId).val();
if(fieldvalue!=undefined && fieldvalue.trim()!=""){
var ntwidvalue=ntwidvalue+""+$(this).attr("id")+"~~~"+parseFloat(fieldvalue)+"~~~~";
}else{
$('#'+id).val("");
}
});
console.log("aaaa");
$('button').click(function(){
var input = $('input');
input.val('ntwidvalue');
input.trigger('input');
});
}
user6782881
source
share