Word到Word – jquery

任何人都知道这是一种描述现金价值或插件的方式吗?

exp:如果我有1.200.000,00和用户hover()的值:描述将是“ 一百二十

谢谢!

以下页面提到了一个非常简单的实现:

字数| 使用Javascript

可以使用此function执行转换:

 var words = toWords(num); 

使用jQuery,你可以将它包装在你的hover函数中,如下所示:

 //This will add a tooltip upon hovering with the "word" value. $('div').hover(function(){ $(this).attr('title',toWords($(this).text())); }); 

工作演示

应检查此示例的来源,通过一些修改,您应该能够实现此目的:

http://abhisanoujam.blogspot.com/2009/07/having-fun-with-jquery-numbers-to-words.html

这是一个紧凑且运行良好的Javascript解决方案:

数字到单词

它可以像这样使用:

 var words = toWords(num); 

validation文本框只允许一个点

 if(!document.getElementById("per").value.match(/^[0-9]*\.?[0-9]*$/)) //"per" is the id text box { alert("Enter Correct Interest Rate"); return (false); } 

我希望这可能有所帮助。

 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'); }); }